ravikumar10 / genyris

Automatically exported from code.google.com/p/genyris
Other
0 stars 0 forks source link

Macros use stack. #58

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Create an infinitely recursive macro.

defmacro incrloop (i)
  print i
  template
      incrloop ^,(+ 1 (eval i))

call it:
> incrloop 0

What do you see?
...
quote 6578
quote 6579
*** Error - 'Stack Overflow'
'<EagerProc: print>'
'<LazyProcedure: <incrloop>>' 206 'console'

What is the expected output?
The recursive macro continues three times longer than a similar recursive 
function such as: 
def incrstack (i)
   print i
   incrstack (+ 1 i)
#~ 2018
#*** Error - 'Stack Overflow'
#'<EagerProc: print>'
#'<EagerProc: <incrstack>>' 181 'console'

However I had expected the macro to evaluate in the environment of the caller, 
and hence continue indefinitely. Perhaps macro execution needs to return a 
'bubble' object which the higher level must detect and evaluate? Just like the 
RefLisp trampolining solution.

But adding a 'bubble' mechanism would give us goto, (recur) like Clojure 
amongst other fun ideas. Hmmmm You would need eager and lazy bubbles.

Original issue reported on code.google.com by birchb1...@gmail.com on 4 May 2013 at 5:06

GoogleCodeExporter commented 9 years ago
Fixed in 0.7.3-1 7a89c0246a2e165b79b759be60c09f8c70ba8988

Original comment by birchb1...@gmail.com on 5 May 2013 at 9:14