<<19-06-2012>>

01:14:44*filwit quit (Quit: Leaving)
09:29:22*Trixar_za is now known as Trix[a]r_za
10:29:58*Araq_ joined #nimrod
10:40:24*Araq_ quit (Quit: ChatZilla 0.9.88.2 [Firefox 13.0.1/20120614114901])
12:27:24*Araq_ joined #nimrod
12:30:10*Araq_ quit (Client Quit)
14:15:09*Trix[a]r_za is now known as Trixar_za
14:32:42*Trixar_za is now known as Trix[a]r_za
15:05:07*Trix[a]r_za is now known as Trixar_za
15:06:09*Trixar_za is now known as Trix[a]r_za
17:02:31*gf3 quit (Ping timeout: 276 seconds)
17:05:04*gf3 joined #nimrod
17:16:15*gf3 quit (Ping timeout: 246 seconds)
17:19:45*gf3 joined #nimrod
17:47:21*apriori_ joined #nimrod
18:06:38*silven joined #nimrod
18:24:59apriori_hi guys
18:25:07apriori_is there an example on how to use macros?
18:25:19apriori_like, traversing the AST
18:33:22Araqapriori_: yes, but I have no time, sorry
18:35:16apriori_ok, np
18:35:22apriori_gonna find it out myself anyhow
19:00:01apriori_am I assuming right, that nimrod macros don't like recursion?
19:02:20dom96I would guess so, yes.
19:03:02apriori_so one stupid question again ;)
19:03:16apriori_am I actually able to recursively traverse ASTs using nimrod asts?
19:03:35apriori_ohm, nimrod macros, I meant
19:04:53*dom96 has no idea
19:05:00dom96I never went that far
19:05:24apriori_ok
19:05:48dom96Are you just playing around, or is there something you are trying to accomplish?
19:07:33apriori_first I
19:07:37apriori_first I'm playing around
19:08:02apriori_when I get to used to this stuff and see its doable what I want, I gonna start "trying to accomplish" something
19:08:11apriori_:)
19:08:50apriori_what I want to try to do is to automatically transform some statements into opencl code
19:09:20apriori_and the macro invocation itself shall transform the respective code point to a call into a dispatcher
19:09:55apriori_so 1st: parse the AST and transform it something that opencl can understand 2. make nimrod call the opencl kernel instead of the code that was written
19:11:37dom96hrm, I might have an example that might help you. Let me see if it still works :P
19:11:48apriori_thank you ;)
19:11:57apriori_what is kinda striking, is, a simple test case:
19:12:27apriori_http://codepad.org/pft53XdI
19:12:30*ponce left #nimrod (#nimrod)
19:12:43apriori_in the dump macro, if you replace the nil in the for loop the compiler will start complaining "can't evaluate"
19:13:06apriori_I tried replacing it with a nother call to dump(n[i])
19:13:24apriori_oh well, replace the "when" with "if"
19:13:48apriori_with "when" i assumed the compiler might have issues with the termination of the recursion
19:16:23dom96hrm
19:17:13apriori_http://codepad.org/iHA5rJQm
19:17:18apriori_exact code I'm trying
19:17:23apriori_just let it "analze" a for loop
19:17:28apriori_analyze
19:20:16dom96Yeah, macros are still quite buggy I think.
19:20:21dom96I just crashed the compiler...
19:20:41apriori_I guess you tried replacing the "if" with "when"?
19:20:45apriori_the same happens here, then
19:20:59dom96nah, I did something silly. In fact it's my fault lol
19:21:08dom96The compiler shouldn't crash anyway though
19:21:42dom96I called dump(n) again at the top of the `dump` macro
19:21:49apriori_ouch ;)
19:23:19dom96If you replace your dump(n[i]) with treeRepr(n[i]) it works.
19:23:46apriori_yeah, but thats no recurson,t hen
19:24:04apriori_Its not, that I just simply wanna "print" the tree... I want to try, whether its possible to recursively travers the tree
19:24:21apriori_and the question is... do I actually need a macro for that or will a proc suffice?
19:24:35apriori_if so.. how do I pass on the statement "stmt" AST to the proc?
19:25:37dom96As far as I know procedures cannot work with "stmt"
19:25:44dom96Only templates and macros can.
19:26:02dom96I think it's quite possible that recursive macros just don't work yet.
19:26:06apriori_yeah, I know that.. but they should be able to work with PNimrodNode (I mean, the module "macros" contains a lot such procs")
19:26:27dom96oh yeah. You can make them work with PNimrodNode, of course.
19:26:46apriori_and how do I get from stmt to PNimrodNode? :)
19:26:56dom96Yeah, if you traverse the AST using a proc it might work better than recursively calling the macro.
19:27:14apriori_yeah.. for only traversing
19:27:21apriori_but if you want to replace modify in-place, you need a macro..
19:27:25apriori_or well.. a template
19:28:18dom96Couldn't you just modify the AST and return the resulting PNimrodNode?
19:28:35dom96Edit it in a proc and then return the result in the macro.
19:29:39apriori_well.. got a problem with a test proc already:
19:29:56apriori_http://codepad.org/blqUsVcw
19:30:01apriori_just modified dump to a proc:
19:30:06apriori_helloworld.nim(27, 10) Error: cannot generate code for 'kind'
19:30:17apriori_which is the "if" statement beginning in dump
19:30:38dom96I think you need to mark the proc as compile time with the {.compileTime.} pragma
19:31:39dom96hrm, the treeRepr function in macros.nim actually uses recursion.
19:31:40apriori_prior to the declaration ?
19:31:56dom96proc dump(n: PNimrodNode) {.compileTime.}
19:32:03apriori_k
19:32:11dom96Take a look at macros.nim line 278
19:32:22apriori_in case of having code proc dump(n:...) {.compileTime] .. code ?
19:32:32apriori_on it
19:32:51apriori_ah, k
19:33:27Araqapriori_: macros can be recursive
19:33:45Araqas you noted macros.nim contains examples how to traverse the tree
19:33:56apriori_dom96: recursive proc is working after adding compileTime
19:33:56Araqand please if you make the compiler crash, fill in a bug report :-/
19:34:06apriori_Araq: yeah, that should be enough
19:34:15apriori_gues I need to read the lib source a lot more ;)
19:34:17apriori_*guess
19:34:23apriori_yeah, will do
19:34:46Araqin fact, I thought we have some heavy tests for them
19:34:56Araqglad to hear it's still crap :-(
19:35:54apriori_ah, nvm...
19:36:00apriori_guess I just wrote completely fucked up code ^^
19:36:18apriori_trying to undo until I find the case again in which it crashed
19:36:44dom96https://github.com/Araq/Nimrod/issues/141
19:36:47dom96I just reported that.
19:37:44apriori_Araq: if you happen to have a minute, look over this version of the dump macro.. and tell me whether its bullshit ;)
19:37:47apriori_http://codepad.org/XoQywdQv
19:37:51apriori_it crashes the compiler at least
19:38:36apriori_dom96: in your case you got infinite recursion
19:38:56dom96Yeah, well the compiler shouldn't crash anyhow ;)
19:39:27apriori_ok ;)
19:39:49apriori_I don't know whether its actually easy to detect such cases..
19:40:07apriori_I guess.. this whole problem is the sole reason for ATS recursion termination metric thingy
19:40:45Araq*shrug* the compiler has recursion checks for everything
19:40:52Araqwell I thought so :-)
19:40:57apriori_hehe
19:40:58dom96Araq: Don't worry, the times I make the compiler crash nowadays is because I do something stupid :P
19:42:11Araqrecursion termination thingy is too restrictive for the compiler
19:42:32Araqit's *supposed* to contain an AST interpreter after all ...
19:42:45Araqit's non terminating by its very nature
19:43:02apriori_yeah... in a way ;)
19:43:16apriori_I'm not that familiar with all the theory behind it..
19:45:19Araqoh well
19:45:29Araqat least nimrod has the prettiest stack traces :P
19:46:39dom96Hell yeah.
19:47:11apriori_hm...
19:47:18Araqhm my evals.nim does not contain any indexing operation in line 506
19:47:26Araqit's outdated I suppose
19:47:27apriori_I must be somewhat stupid.. but i cant get it to work with a recursive macro:
19:47:45Araquse a recursive compiletime proc then :P
19:47:51apriori_http://codepad.org/ucUC2OHj
19:48:02Araqrecursive macro does not have the semantics you think they have
19:48:17apriori_maybe
20:06:08apriori_thanks for your help guys, I gotta go now
20:06:10apriori_bye
20:06:13*apriori_ quit (Quit: Konversation terminated!)
20:15:23Araqwell zahary what should we do with bug #140?
20:15:40Araqmake it a proper error? introduce an implicit block?
20:21:28zaharyI think it should work - my example look silly, because I wanted it to be minimal, but the real code in which I discovered the problem was more meaningful
20:21:28zaharyit was something like
20:21:28zaharyyield start_value # before loop
20:21:28zaharywhile loop: yield more_values
20:22:44zaharywhen you work on coroutines, do you plan to keep the existing inlining implementation too?
20:22:54Araqsure
20:23:32Araqwell we need to put yields outside of loops into blocks then
20:23:52Araqso that 'break' has something to leave
20:23:58zaharybecause with the classic yield as state = X; return, this won't happen. I haven't studied yet the current implementation
20:24:50Araqbtw what's a "yield break" in C#? I never used it :D
20:27:51zaharyit's like a return - interrupts the iteration without producing a new value
20:30:28Araqdo we need it too?
20:31:37zaharywe have return that does the same
20:32:39Araqwe have no 'return' in iterators ...
20:33:10zaharyI'm trying it right now :)
20:33:14zaharywhat will happen?
20:33:27Araqcompiler should reject it
20:34:00zaharyyep, I got a clean error
20:34:27zaharywell, I don't know then - I usually vote to support everything that's available elsewhere
20:34:39AraqI noticed ;-)
20:35:11AraqI usually let the implementation decide :P
20:35:27Araqif it's easy to do, I may do it :-)
20:38:07Araqso zahary can you please get rid of the strange gensym syntax and make templates hygienic? :-)
20:38:15Araqor should I do it?
20:38:33Araqand please write docs for the features you implement
20:41:13zaharyI read a paper about the implementation of recursive iterators some time ago - http://research.microsoft.com/en-us/projects/specsharp/iterators.pdf
20:41:13zaharyIt talks about proof-carrying code for invariants, but besides that it has some direct example code for the implementation after the transformations (they claim their method is better than the original C# compiler and it's likely to be incorporated in future versions)
20:41:14zaharyabout the docs: yeah, yeah, I know
20:42:10zaharyI'd like to fix the gensym problem, but I'll a bit more busy the next few days
20:42:23zaharymaybe the weekend
20:44:31Araqwell I'll do it then
20:44:41Araqit's the next item on my todo list
20:59:57Araqhey!
21:00:14Araqsome commits are missing
21:00:17Araqdom96?
21:00:52dom96Araq: IIRC NimBot doesn't announce them all.
21:00:59Araqalright
21:01:00dom96Although it should say "x more commits"
21:01:05dom96So that's a bug.
21:01:17Araqok fix it :P
21:01:25Araqand have fun with the closures
21:02:12*JStoker quit (Excess Flood)
21:12:11*JStoker joined #nimrod