Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Tail end recursion

From: maarten:vrijheid at: 9-Oct-2003 15:18

> Thanks for that. I look forward to the day that I can > understand it :)
Well, it took some time to write it ;-) It is a very powerful demonstration of REBOLs ability to do most things you want if *you* are up to it. What does this script do? It creates a "hidden" context using the 'use construct. The value returned from the code block of 'use is a function that has access to all these words/values. So... the use context can act as an extra stack frame. This is exactly what it does: it sets a flag for a function (metafunc) to inidicate recursive calling. Innerfunc is inside metafunc and is your actual code. Metafunc simply counts and implements a goto with throwing away the current stack frame (local words). All the p1 and p2 stuff is to pass/count refinements. Enjoy your headache ;-) --Maarten