<<03-07-2012>>

00:51:54*Trixar_za is now known as Trix[a]r_za
02:10:46*XAMPP[0] quit (Ping timeout: 246 seconds)
08:46:19*JStoker quit (Excess Flood)
08:47:46*SchalaZeal joined #nimrod
08:48:10SchalaZealDoes anyone know how to pass an array to a proc expecting a pointer parameter?
08:50:59TasserSchalaZeal, addr() gives you the pointer
08:51:29SchalaZealAh, thanks
08:57:47*JStoker joined #nimrod
09:05:26SchalaZealcmd.exe....... weirdest thing ever
09:06:07SchalaZealpart of the data in the stream I sent over a socket, when I echo'd it appeared as different variants of smiley face symbols
09:06:50SchalaZealbut other than that, I got the behavior I wanted
09:11:28SchalaZealI'm in the process of trying to code some more internet protocol modules to contribute
09:11:50SchalaZealsince IRC is the only one
09:12:35TasserSchalaZeal, powershell? ^^
09:12:51TasserSchalaZeal, http? :-)
09:14:00SchalaZealwell... uhm... were you on the internet in the late 90s?
09:14:55SchalaZealcause I just wrote a minimalistic client for a protocol called Hotline that's pretty much....ancient
09:15:11SchalaZealbut was innovative back in the 90s
09:17:14Tasserthey had internet back then? :-)
09:17:39SchalaZealhttp://pastebin.com/H5eJFJQr
09:18:22SchalaZealall it does is do a successful handshake if its connection to one of the few remaining servers on there is successful
09:19:10SchalaZealsends the message TRTP and 2 int16s with the values 1 and 2
09:19:34SchalaZealshould receive from the server TRP and an int16 with the value 0
09:19:39SchalaZealerr TRTP**
09:19:48SchalaZealoops
09:19:56SchalaZealit sends TRTPHOTL I meant
09:20:03SchalaZealhehe
09:21:19SchalaZealit needs to be able to handle transactions if it's going to be actually useful though
09:22:06SchalaZealthat's what I'm going to be going with my 'hotline' module
09:22:56SchalaZealdoing**
09:25:09SchalaZealProtocol documentation is at http://hotline.wikia.com/wiki/Protocol and http://hotline.wikia.com/wiki/Virtual1%27s_Hotline_Server_Protocol_Guide
09:36:29Tassernever heard of
09:44:04SchalaZealeh it was one of those underrated things
09:44:30SchalaZeal1 million users at its peak I think
09:45:42SchalaZealplus I think a Second Life server written in Nimrod would be far too difficult, if not impossible
09:48:23SchalaZealNot that I think Nimrod's incapable of doing that but........ I have yet to see anyone do something major with it such as an MMO or.......something
09:48:54SchalaZealmost I've seen is a space invaders clone
09:49:28SchalaZealerr most complex rather
09:52:05SchalaZealI have no doubt it has more potential of course. Nimrod's just under the radar right now. Wikipedia page got deleted even
10:01:17Tasserouch
10:14:10SchalaZealyeah
10:14:42SchalaZealanyway... got an outline for the module..... tomorrow I code..... if it's too hot to learn 3D modelling some more
10:15:27SchalaZealguten nacht everyone
10:15:31*SchalaZeal quit ()
10:51:34*zahary quit (Ping timeout: 246 seconds)
14:46:58*XAMPP joined #nimrod
18:43:59*zahary_ joined #nimrod
19:29:21Araqhi zahary_
19:50:34*XAMPP quit (Quit: There is no such thing as coincidence, only the inevitable.)
19:51:14*XAMPP joined #nimrod
19:51:15*XAMPP quit (Changing host)
19:51:15*XAMPP joined #nimrod
20:07:43TasserAraq, hmm, do you plan on implementing anything like interfaces?
20:07:57AraqI have a deja-vu ...
20:08:02Tasseryep, I know :-)
20:08:08Araquse a tuple of closures
20:08:16Tasserhuh?
20:08:21Araqthey should work by now
20:11:17Tassergot an example somewhere?
20:11:40TasserI don't see how a tuple of closures gives me an interface
20:14:56Araqthere is an example on the forum somewhere :P
20:16:00Tasserhum
20:16:38Araqhttp://forum.nimrod-code.org/t/31
20:17:56Tasserhum
20:18:39TasserI see interface as a solution to the "I require a data type that has a function called X and one called Y" problem
20:19:36AraqI see an isomorphism between "tuple of closures" and "interface" :P
20:19:54Tasser^^
20:20:31Tasserwould be nice to have some support for that problem by the type system though
20:21:47Araqyeah but the problem is:
20:22:19AraqNimrod's creator despises any form of dynamic binding
20:22:50Tasserand callbacks?
20:24:26Araqit doesn't matter if it's a "callback" or a "function pointer" or a "closure" or an "interface" or a "multi method" or an ordinary "method"
20:24:50Araqit's a necessary evil ;-)
20:24:58Araqbut I will never embrace them
20:25:27TasserI'm not exactly sure how Gos type system works... does it assign types by functions defined?
20:26:05Araqit more or less attached procs to a type for the interfaces to work
20:26:26Araqas the procs must be in the same module (or perhaps package)
20:26:50Tasserand I suppose dynamic types would be the evil himself? ^^
20:27:25Araqwell as usual you should be able to do something with macros and converters
20:27:49Araqconvert toIface(x: MyObject): MyInterface
20:28:00Tasseryou loose MyObject as type information
20:28:11Araqthat's the point
20:28:17Araqisn't it?
20:29:04Tasserit's not to replace the type, but rather add a new one without removing the old one
20:29:27Araqbtw Ada 83 had no function pointers nor any other means to get a callback afaik
20:29:54Araqas that enables tools to get a *complete* call graph
20:30:04Araqand you can then prove the heck out of your code
20:31:01Tasserwhat's the approach to the problem a callback solves? (call a function whenever X happens)
20:31:30Araqin Ada83 you would work around with an event dispatching mechanism I think
20:31:38Araqthink of how SDL does it
20:31:53Tasseruhm, information leak there
20:32:11Tasserwhere do I read up how SDL does it?
20:32:24Araqwhile peekEvent(ev):
20:32:31Araq case ev.typ
20:32:37Araq of mouseClick: ...
20:32:40Araqetc.
20:32:57Araqyou get the idea
20:33:17Tasserso when the event happens, you don't go down but up the call stack
20:33:56Araqmore or less
20:34:10Araqyou store the event in a queue and let the client ask for it
20:34:52Araq"tell don't ask" is not good for verification
20:35:16Araqbut I digress
20:35:49Tasserisn't iterator chaining kind of a callback?
20:36:29Araqwhat do you mean?
20:36:44Araqnimrod's iterators don't use callbacks
20:36:54Araqand Ada83 does not even have iterators
20:38:14Araqhowever
20:38:25*zahary_ is now known as zahary
20:38:30zaharyhi
20:38:31Araqcallbacks are actually easier to analyse than (multi) methods
20:38:51Araqas the dispatching is harder to track for methods
20:39:12Araqzahary: is the C++ exception handling working and stable?
20:40:35zaharyI haven't tested it much, but I don't see many things that could go wrong with it (also, nimrod bootstraps fine with it enabled)
20:41:29Araqbootstrapping is not a very good test for exceptions
20:41:42Araqmuch better is "nimrod check" with an errornous file
20:41:46zaharywell, there are some try blocks in the compiler
20:42:17Araqyeah but "nimrod check" or "nimrod suggest" actually triggers them
20:44:05zaharyI was thinking about running the test suite in cpp mode (also in "nimrod i" mode too)
20:46:33Araqthat's a good idea :-)
20:46:57Araq"nimrod i" won't fly for the test suite, but "cpp" should be easy
20:48:06AraqI could some simple tests to work with the JS backend and node.js :D
20:48:34Araqexceptions are still quite broken in the JS backend
20:48:46zaharyI've tried nimrod i manually on some tests and it works most of the time
20:49:18zaharymy guess is that there will be some false positives, but it's likely to reveal some bugs in the interpreter too
20:49:46Araqbut lots of tests use "system.write[ln]" for a start
20:49:58Araqand we still have no IO support
20:51:37zaharythey could be written to use echo instead - you used system.write to avoid newlines, but if that's desired maybe the tester could simply ignore newlines in the output if told so
20:52:23Araqtry but the tester actually now supports newlines
20:52:42fowlhow do i bring a union from c
20:53:05Araqfowl: c2nim can do it ;-)
20:53:18Araqwell not really; it uses the first field of the union
20:53:30Araqin the hope that it has the maximum size
20:53:51zaharyfowl, in general you cheat and add overloads and unsafe casts to represent the alternative fields
20:54:47fowlthat doesnt sound fun :<
20:55:01Araqyeah, C interfaces with everything very well; until you take a closer look ;-)
20:55:49Araqfowl: most APIs do not require you to access the union's fields directly
20:56:07Araqit's often enough to get the size of union right
20:58:07fowlim working on porting allegro, so far it loads and displays images
20:58:25Araqawesome
20:58:27zaharyfowl, you can have a template to automate the dirty work
20:58:27zaharytemplate union_view(T: typedesc, field, field_type: expr) =
20:58:27zahary proc `field`(x: var T): var field_type =
20:58:27zahary result = cast[ptr field_type](addr(x))[]
21:05:34Araqzahary: I'm thinking (and in fact writing some code) about the matching of ASTs
21:05:40Araqfor the HLO
21:06:27Araqand the patterns are hard to match I think
21:06:34zaharyI hope it's in sem.nim :)
21:06:48Araqit's in a separate module for now ;-)
21:06:59Araqbut that's what I'd like to talk about
21:07:13Araqthere are 2 use cases, much like for macros
21:07:26Araqimmediate vs "ordinary"/after type checking
21:07:51Araqbut "immediate" really causes problems for term rewriting
21:08:48zaharywhat kind of problems?
21:09:03Araqa + b * c
21:09:22Araqwe could make a first pass and annotate atoms with types
21:09:38Araqand then try to match the pattern
21:10:10Araqbut I think it's always possible to introduce "dummy" ordinary operators
21:10:22Araqto make the desired expressions type check
21:10:31Araqand then run the pattern matching over them
21:11:16Araq(the example I have in mind is: proc {x + y * z} (x, y, z: float): float = ... )
21:12:31Araqthe pattern matching may of course rule out some combinations afterwards with the .error pragma
21:12:57Araqwhat use cases do you have in mind for "immediate" patterns?
21:13:49Araqfor the use cases I have in mind, it always suffices to semcheck before pattern matching
21:14:37zaharyhow will matching proceed here?
21:14:38zaharyI imagine nkInfix with * will be the "head of the pattern" - when it's encountered in sem, its children are passed to semExprWithType and then they either match the expected types or they don't
21:15:15zaharyso the recursive nature of semExprWithType is something similar to the "first pass" you mentioned
21:15:35Araqwell the matching is quite sophisticated as it supports unification and wildcards etc. (we talked about it)
21:15:54Araqand my plan is to run it as part of semcheck
21:16:03Araqbut after overloading resolution
21:16:33Araqmuch like non-immediate templates
21:17:09zaharymy thinking was that even the more sophistacated patterns have such a "pattern head" node that can be matched as a first step in semExpr
21:17:22zaharyalmost directly from a lookup table
21:17:44Araqthere is not necessarily a "pattern head"
21:17:59Araqwell ok there is
21:18:04Araqbut it's too general
21:18:14Araqand all the cases I look at
21:18:20Araqrequire proper type information
21:18:26Araqit doesn't make sense to transform
21:18:30Araqx * 0 -> 0
21:18:36Araqif you don't know x's type
21:19:30Araqmacros get around it as they then work like keywords
21:19:44Araqbut this doesn't work for generalized patterns
21:21:02zaharyI think a good parallel would be if you think about nkIfix as some kind of proc that participates in overload resolution
21:21:02zaharywhen you encounter it and there is a pattern that uses it as head you just try to apply the "standard" overload resolution algorithm over the node
21:21:11zaharyyou treat the sons as params
21:21:57zaharywildcards, etc are somewhat similar to varargs params in this analogy
21:24:50Araqsay I have a ternary operator, x ? y ! z
21:25:19Araqan immediate pattern then is the same as a syntax extension
21:25:41Araqwhich is against nimrod's philosophy
21:26:01Araqsince once you reach this point
21:26:08Araqyou should use a string literal and compile-time parser
21:26:50Araqinstead you need to make Nimrod parse and type check (x ? y) | z
21:27:02Araqand then you can match over it
21:27:19Araqer, I mean (x ? y) ! z
21:28:15Araqbut my point is: collect use cases for your way ;-)
21:28:29zaharyalright, but what's the problem? you imply that there must exists a separate well defined operator "?" ?
21:28:38Araqyes
21:28:54Araqin fact, we can accept 'expr' as a type
21:29:09Araqand require proper types only after pattern matching
21:33:06Araqbut hm
21:33:23Araq"stride" was a good use case
21:34:13Araqx[2..4 :+ 3] # slice with step 3
21:35:03Araqit's a bit annoying to make a slice[int] out of '..' and then take a slice and an int to get a stride type
21:35:07zaharyI don't see the AST-level transformations as something bad, but even this viewpoint don't conflict too much with the "overload resolution" approach I mentioned - since overload resolution composes fine when there are multiple nested type checked calls (foo(bar(baz)) the same will be true for patterns
21:36:14Araqand then you have proc `[]`(x: array, s: stride)
21:36:29Araqonly to optimize it all away in a pattern matching step
21:37:06Araqon the other hand, it's not to horrible I think
21:37:07zaharymy latest thinking is that "inter-statement" patterns (the ones that merge several lines of code into 1) are more valuable than single-expression patterns since these are quite isomorphic to normal use of templates
21:39:58Araqbut for them you need the types even moreso
21:40:21Araqthe more complex the pattern the more useless it is
21:40:31zaharywell, yes - do I imply somehow that the types are not needed?
21:40:52Araqwell yes
21:41:10Araqas you have some different matching algorithm in mind than me :-)
21:42:06Araqbtw what do we do with the fixpoint iteration? screw the idea? only via command line switch?
21:42:16Araqalways do it?
21:42:27zaharyhmm, where? I said you should do semExprWithType on the sons, before passing them to standard overload resolution algorithms
21:43:09Araqyes but overload resolution only handles a single call
21:43:40Araqand so it can be performed bottom up
21:43:48zaharybut my point was that each pattern has a "head" that looks like a single call
21:44:25Araqyes
21:44:31Araqbut how does it proceed then?
21:44:38AraqsemExpr() =
21:44:54Araq if n.kind in pattern.kind:
21:45:11Araq ... what here ...?
21:47:35zaharyif not patterns[n.kind].empty:
21:47:35zahary # try to match
21:47:35zahary # make sure semExprWithType is called only once for each son even tho we'll try to match several patterns
21:47:35zahary # maybe apply my lazy typing scheme where semExprWithType is not called if the pattern has a expr{NodeKind} param types
21:47:35zaharyproceed
21:49:38zaharyit also makes sense to optimize a bit further nkCalls, nkInfix, etc with additional table keyed on the first symbol
21:50:27Araqeither I don't get it
21:50:41Araqor you propose the same algorithm as I do
21:51:12Araqas the lookup table per node kind is only an optimization?
21:51:47Araqwhich I'm not worried about for now
21:52:39zaharymaybe I was fouled by what you meant by "after overload resolution" - I imagined that you run semExpr to end and then you try to do some additional steps with the results
21:53:23zaharywhat I suggest is that this is an alternative path in semExpr - you either exit through the pattern match path or though the current path
21:54:10Araqhm yes
21:54:16Araqbut it's the same:
21:54:40Araqyou have a pattern's "head"
21:54:47Araqyou semExpr every son
21:55:25Araqthe pattern fails, but you ensure semExpr is called only once (per flag I assume)
21:55:41Araqordinary semExpr proceeds
21:56:00Araqand then you need to check for the pattern again
21:56:12zaharyproceed if the pattern didn't match is what I meant
21:56:14Araqas the pattern's head is not nearly enough
21:56:41Araqyeah I'm talking about the case where the pattern doesn't match in semExpr
21:56:47Araqbut afterwards
21:58:52Araqthere is a difference if the pattern matches in the first pass already
21:59:45Araqbut maybe I still don't get it:
21:59:53Araqa!b!c
21:59:59Araqis (a!b)!c
22:00:11Araqin the tree representation
22:00:53Araqor lets make it a!(b!c)
22:01:07Araqfor my explanation
22:01:19Araqso you semExpr 'a'
22:01:35Araqand then you semExpr 'b!c'
22:01:50Araqbut this fails if you have no binary operator '!'
22:01:59Araqyou can't do
22:02:10Araqtemplate {a!b!c} ...
22:02:16Araqand expect it to work
22:02:19zaharywell, the head head is nkInfix !
22:03:05zaharyit expects 1 typed son and a "subpattern" - another nkInfix !
22:03:21zahary* the head here *
22:03:45Araqah
22:03:49AraqI finally got it
22:04:05Araqso you basically check for the AST structure first
22:04:14Araqand then you if the structure matches
22:04:20Araqyou perform semExpr
22:04:26Araqon the sons (deeply)
22:04:35Araqand then you check the types match for the pattern?
22:04:52zaharyyes, I would say you check the AST structure and the types in parallel in the recursive process
22:05:07Araqargh
22:05:31Araqso you check them in parallel ... hm
22:09:42AraqI will think about this :-)
22:09:52Araqbut again:
22:09:58Araqwhat's the actual use case for this?
22:10:48Araqif you build the DSL piece by piece as pegs does it
22:11:01Araqand you then have optimizing patterns
22:11:08Araqyou gain composability
22:11:36fowlhow long have you two been programming
22:11:41Araqand it's much easier to understand and you can pass subexpression as first class objects
22:12:18zaharywell, I see this as relatively efficient implementation of the HLO (and also consistent with the rest of the language, because it will reuse the algorithms in sigmatch) - otherwise the use cases are what we have discussed already
22:12:36Araqwell it's been a while
22:13:13AraqI can only remember *my* examples :-/
22:13:34Araqand they all work fine with my somewhat simpler approach
22:14:25zaharysome use cases from the top of my head
22:14:25zahary1) eliminating temporary objects in expressions like
22:14:25zahary"a" & "b" & "c" (with other types and operations similar in costs to string concatenation)
22:14:55Araqthat's the standard use case :-)
22:15:33Araqfowl: I've been programming for 12 years I think
22:15:48Araqmaybe for 14 years
22:16:02zaharyI probably for 10
22:17:16Tasserwow
22:19:38AraqI have to sleep soon
22:19:40zaharymy a bit less standard examples were proxy types and the Option[T] optimizations
22:19:40zaharyvar o: Option[T] = something
22:19:40zaharyif o: # pattern match here to establish that the option is "proven" existent in the block
22:19:40zahary # use the dependent type information to elimate any further checks
22:20:16Araqthat's insane ;-)
22:20:54Araqyou need more than the HLO to do that I think
22:21:14Araqwell it depends on the wildcard capabilities
22:22:15Araqbut you need to ensure 'o' is not re-assigned
22:22:28Araqso it only works with 'let' etc.
22:23:21Araqand the question remains: if you do it interlocked with the rest of semantic checking
22:23:23zaharythat's how my hypolang was supposed to work - you can overlay the "if call" to set compile time property in the block
22:23:23zaharynew assignment will wipe out the value of the compile time property
22:24:00Araqthen how do specify the fixpoint computation?
22:24:34zaharycan you clarify what do you mean by that?
22:24:55Araqin the old HLO design I had an iteration step
22:25:12Araqit would only stop if there are no optimizations left to perform
22:25:30Araqor some counter overflowed to prevent endless loops
22:25:47Araqthe counter was by pattern, so every pattern may trigger -say- 100 times
22:26:02zaharyso the question is what are the terminating conditions?
22:26:29Araqthe question is whether you want that to introduce into the semantic checking phase ...
22:26:39Araqbut I can guess your answer ...
22:27:24Araqand the next question is *why* we need a fixpoint computation in the semantic checking phase; it can only hurt IDE support
22:27:54AraqI don't want the compiler to do crazy optimizations for doing intellisense
22:30:09AraqI guess the real question is:
22:30:24Araqwhat use cases are there that are *not* optimizations?
22:32:26Araq*cough* for optimizations my old design was quite good (on paper at least)...
22:32:58Araqbut I have to sleep now
22:33:00zaharywell, the proxy types are not optimizations and they could be considered patterns with nkCall head
22:33:33zaharyI surely can come up with varios perverse DSL uses, but you probably wont like these :)
22:33:55Araqah maybe
22:34:19Araqbut yeah I forgot about the AOP stuff
22:37:13Araqso yeah tell me your perverse DSL uses tomorrow
22:37:18Araqgood night
22:37:49zaharygood night
23:11:13*Trix[a]r_za is now known as Trixar_za
23:26:17*SchalaZeal joined #nimrod
23:27:21SchalaZealHaving some trouble with arrays and pointers. I know in C, you can use a pointer as an array. However I don't know what to do in Nimrod
23:30:15Trixar_zaAraq probably wrote in a way to do the same in Nimrod, but I'm not sure how to do that. Most of them have gone to bed though, SchalaZeal.
23:30:36SchalaZealhmm ok
23:31:01Trixar_zaJust post it on the forum and they'll get to it tomorrow
23:31:09SchalaZealok
23:31:22Trixar_zaor in my case, today, since it's 1:30am :P
23:38:24SchalaZealheh