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:59 | apriori_ | hi guys |
18:25:07 | apriori_ | is there an example on how to use macros? |
18:25:19 | apriori_ | like, traversing the AST |
18:33:22 | Araq | apriori_: yes, but I have no time, sorry |
18:35:16 | apriori_ | ok, np |
18:35:22 | apriori_ | gonna find it out myself anyhow |
19:00:01 | apriori_ | am I assuming right, that nimrod macros don't like recursion? |
19:02:20 | dom96 | I would guess so, yes. |
19:03:02 | apriori_ | so one stupid question again ;) |
19:03:16 | apriori_ | am I actually able to recursively traverse ASTs using nimrod asts? |
19:03:35 | apriori_ | ohm, nimrod macros, I meant |
19:04:53 | * | dom96 has no idea |
19:05:00 | dom96 | I never went that far |
19:05:24 | apriori_ | ok |
19:05:48 | dom96 | Are you just playing around, or is there something you are trying to accomplish? |
19:07:33 | apriori_ | first I |
19:07:37 | apriori_ | first I'm playing around |
19:08:02 | apriori_ | when I get to used to this stuff and see its doable what I want, I gonna start "trying to accomplish" something |
19:08:11 | apriori_ | :) |
19:08:50 | apriori_ | what I want to try to do is to automatically transform some statements into opencl code |
19:09:20 | apriori_ | and the macro invocation itself shall transform the respective code point to a call into a dispatcher |
19:09:55 | apriori_ | 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:37 | dom96 | hrm, I might have an example that might help you. Let me see if it still works :P |
19:11:48 | apriori_ | thank you ;) |
19:11:57 | apriori_ | what is kinda striking, is, a simple test case: |
19:12:27 | apriori_ | http://codepad.org/pft53XdI |
19:12:30 | * | ponce left #nimrod (#nimrod) |
19:12:43 | apriori_ | in the dump macro, if you replace the nil in the for loop the compiler will start complaining "can't evaluate" |
19:13:06 | apriori_ | I tried replacing it with a nother call to dump(n[i]) |
19:13:24 | apriori_ | oh well, replace the "when" with "if" |
19:13:48 | apriori_ | with "when" i assumed the compiler might have issues with the termination of the recursion |
19:16:23 | dom96 | hrm |
19:17:13 | apriori_ | http://codepad.org/iHA5rJQm |
19:17:18 | apriori_ | exact code I'm trying |
19:17:23 | apriori_ | just let it "analze" a for loop |
19:17:28 | apriori_ | analyze |
19:20:16 | dom96 | Yeah, macros are still quite buggy I think. |
19:20:21 | dom96 | I just crashed the compiler... |
19:20:41 | apriori_ | I guess you tried replacing the "if" with "when"? |
19:20:45 | apriori_ | the same happens here, then |
19:20:59 | dom96 | nah, I did something silly. In fact it's my fault lol |
19:21:08 | dom96 | The compiler shouldn't crash anyway though |
19:21:42 | dom96 | I called dump(n) again at the top of the `dump` macro |
19:21:49 | apriori_ | ouch ;) |
19:23:19 | dom96 | If you replace your dump(n[i]) with treeRepr(n[i]) it works. |
19:23:46 | apriori_ | yeah, but thats no recurson,t hen |
19:24:04 | apriori_ | Its not, that I just simply wanna "print" the tree... I want to try, whether its possible to recursively travers the tree |
19:24:21 | apriori_ | and the question is... do I actually need a macro for that or will a proc suffice? |
19:24:35 | apriori_ | if so.. how do I pass on the statement "stmt" AST to the proc? |
19:25:37 | dom96 | As far as I know procedures cannot work with "stmt" |
19:25:44 | dom96 | Only templates and macros can. |
19:26:02 | dom96 | I think it's quite possible that recursive macros just don't work yet. |
19:26:06 | apriori_ | 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:27 | dom96 | oh yeah. You can make them work with PNimrodNode, of course. |
19:26:46 | apriori_ | and how do I get from stmt to PNimrodNode? :) |
19:26:56 | dom96 | Yeah, if you traverse the AST using a proc it might work better than recursively calling the macro. |
19:27:14 | apriori_ | yeah.. for only traversing |
19:27:21 | apriori_ | but if you want to replace modify in-place, you need a macro.. |
19:27:25 | apriori_ | or well.. a template |
19:28:18 | dom96 | Couldn't you just modify the AST and return the resulting PNimrodNode? |
19:28:35 | dom96 | Edit it in a proc and then return the result in the macro. |
19:29:39 | apriori_ | well.. got a problem with a test proc already: |
19:29:56 | apriori_ | http://codepad.org/blqUsVcw |
19:30:01 | apriori_ | just modified dump to a proc: |
19:30:06 | apriori_ | helloworld.nim(27, 10) Error: cannot generate code for 'kind' |
19:30:17 | apriori_ | which is the "if" statement beginning in dump |
19:30:38 | dom96 | I think you need to mark the proc as compile time with the {.compileTime.} pragma |
19:31:39 | dom96 | hrm, the treeRepr function in macros.nim actually uses recursion. |
19:31:40 | apriori_ | prior to the declaration ? |
19:31:56 | dom96 | proc dump(n: PNimrodNode) {.compileTime.} |
19:32:03 | apriori_ | k |
19:32:11 | dom96 | Take a look at macros.nim line 278 |
19:32:22 | apriori_ | in case of having code proc dump(n:...) {.compileTime] .. code ? |
19:32:32 | apriori_ | on it |
19:32:51 | apriori_ | ah, k |
19:33:27 | Araq | apriori_: macros can be recursive |
19:33:45 | Araq | as you noted macros.nim contains examples how to traverse the tree |
19:33:56 | apriori_ | dom96: recursive proc is working after adding compileTime |
19:33:56 | Araq | and please if you make the compiler crash, fill in a bug report :-/ |
19:34:06 | apriori_ | Araq: yeah, that should be enough |
19:34:15 | apriori_ | gues I need to read the lib source a lot more ;) |
19:34:17 | apriori_ | *guess |
19:34:23 | apriori_ | yeah, will do |
19:34:46 | Araq | in fact, I thought we have some heavy tests for them |
19:34:56 | Araq | glad to hear it's still crap :-( |
19:35:54 | apriori_ | ah, nvm... |
19:36:00 | apriori_ | guess I just wrote completely fucked up code ^^ |
19:36:18 | apriori_ | trying to undo until I find the case again in which it crashed |
19:36:44 | dom96 | https://github.com/Araq/Nimrod/issues/141 |
19:36:47 | dom96 | I just reported that. |
19:37:44 | apriori_ | Araq: if you happen to have a minute, look over this version of the dump macro.. and tell me whether its bullshit ;) |
19:37:47 | apriori_ | http://codepad.org/XoQywdQv |
19:37:51 | apriori_ | it crashes the compiler at least |
19:38:36 | apriori_ | dom96: in your case you got infinite recursion |
19:38:56 | dom96 | Yeah, well the compiler shouldn't crash anyhow ;) |
19:39:27 | apriori_ | ok ;) |
19:39:49 | apriori_ | I don't know whether its actually easy to detect such cases.. |
19:40:07 | apriori_ | I guess.. this whole problem is the sole reason for ATS recursion termination metric thingy |
19:40:45 | Araq | *shrug* the compiler has recursion checks for everything |
19:40:52 | Araq | well I thought so :-) |
19:40:57 | apriori_ | hehe |
19:40:58 | dom96 | Araq: Don't worry, the times I make the compiler crash nowadays is because I do something stupid :P |
19:42:11 | Araq | recursion termination thingy is too restrictive for the compiler |
19:42:32 | Araq | it's *supposed* to contain an AST interpreter after all ... |
19:42:45 | Araq | it's non terminating by its very nature |
19:43:02 | apriori_ | yeah... in a way ;) |
19:43:16 | apriori_ | I'm not that familiar with all the theory behind it.. |
19:45:19 | Araq | oh well |
19:45:29 | Araq | at least nimrod has the prettiest stack traces :P |
19:46:39 | dom96 | Hell yeah. |
19:47:11 | apriori_ | hm... |
19:47:18 | Araq | hm my evals.nim does not contain any indexing operation in line 506 |
19:47:26 | Araq | it's outdated I suppose |
19:47:27 | apriori_ | I must be somewhat stupid.. but i cant get it to work with a recursive macro: |
19:47:45 | Araq | use a recursive compiletime proc then :P |
19:47:51 | apriori_ | http://codepad.org/ucUC2OHj |
19:48:02 | Araq | recursive macro does not have the semantics you think they have |
19:48:17 | apriori_ | maybe |
20:06:08 | apriori_ | thanks for your help guys, I gotta go now |
20:06:10 | apriori_ | bye |
20:06:13 | * | apriori_ quit (Quit: Konversation terminated!) |
20:15:23 | Araq | well zahary what should we do with bug #140? |
20:15:40 | Araq | make it a proper error? introduce an implicit block? |
20:21:28 | zahary | I 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:28 | zahary | it was something like |
20:21:28 | zahary | yield start_value # before loop |
20:21:28 | zahary | while loop: yield more_values |
20:22:44 | zahary | when you work on coroutines, do you plan to keep the existing inlining implementation too? |
20:22:54 | Araq | sure |
20:23:32 | Araq | well we need to put yields outside of loops into blocks then |
20:23:52 | Araq | so that 'break' has something to leave |
20:23:58 | zahary | because with the classic yield as state = X; return, this won't happen. I haven't studied yet the current implementation |
20:24:50 | Araq | btw what's a "yield break" in C#? I never used it :D |
20:27:51 | zahary | it's like a return - interrupts the iteration without producing a new value |
20:30:28 | Araq | do we need it too? |
20:31:37 | zahary | we have return that does the same |
20:32:39 | Araq | we have no 'return' in iterators ... |
20:33:10 | zahary | I'm trying it right now :) |
20:33:14 | zahary | what will happen? |
20:33:27 | Araq | compiler should reject it |
20:34:00 | zahary | yep, I got a clean error |
20:34:27 | zahary | well, I don't know then - I usually vote to support everything that's available elsewhere |
20:34:39 | Araq | I noticed ;-) |
20:35:11 | Araq | I usually let the implementation decide :P |
20:35:27 | Araq | if it's easy to do, I may do it :-) |
20:38:07 | Araq | so zahary can you please get rid of the strange gensym syntax and make templates hygienic? :-) |
20:38:15 | Araq | or should I do it? |
20:38:33 | Araq | and please write docs for the features you implement |
20:41:13 | zahary | I read a paper about the implementation of recursive iterators some time ago - http://research.microsoft.com/en-us/projects/specsharp/iterators.pdf |
20:41:13 | zahary | It 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:14 | zahary | about the docs: yeah, yeah, I know |
20:42:10 | zahary | I'd like to fix the gensym problem, but I'll a bit more busy the next few days |
20:42:23 | zahary | maybe the weekend |
20:44:31 | Araq | well I'll do it then |
20:44:41 | Araq | it's the next item on my todo list |
20:59:57 | Araq | hey! |
21:00:14 | Araq | some commits are missing |
21:00:17 | Araq | dom96? |
21:00:52 | dom96 | Araq: IIRC NimBot doesn't announce them all. |
21:00:59 | Araq | alright |
21:01:00 | dom96 | Although it should say "x more commits" |
21:01:05 | dom96 | So that's a bug. |
21:01:17 | Araq | ok fix it :P |
21:01:25 | Araq | and have fun with the closures |
21:02:12 | * | JStoker quit (Excess Flood) |
21:12:11 | * | JStoker joined #nimrod |