3 ms·
I see that lispy is using instance_exec -- which means that the scope of code inside that code is the lispy instance, which might not be what the programmer exp
by soamv 15y ago
I see that lispy is using instance_exec -- which means that the scope of code inside that code is the lispy instance, which might not be what the programmer expects. For example if he does this inside a method he'd find his instance variables missing. (Is that right, or am I misreading the code?)
You could use some sort of global or thread local variable to maintain the context, and then you wouldn't lose the instance scope, but then this code will not mix well with yield (and continuations and fibers etc.)
So then it looks like the only way to solve this problem really neatly is in a language that has macros.
(I made some attempts at this problem too, at https://github.com/soam/blox https://github.com/soam/blox . It is slightly more complex than lispy; see for example https://github.com/soam/blox/tree/master/samples/webservice https://github.com/soam/blox/tree/master/samples/webservice .)