Hendrik Boom wrote:
> 
> There is a way of doing this.  Implement tail recursion by a regular 
> procedure call, passing it a continuation, but never return -- just call 
> the continuatino instead.
> 
> The stack will grow like mad.
> 
> Every now and then, when the stack gets uncomfortably big, do a longjump 
> out of the whole stack of never-to-be-used activation records, and let 
> the code at longjump target call your continuation for you.
> 
> If you want, you can also allocate heap storage on the stack, if you are 
> careful to do a copying garbage collection before the longjump -- one 
> that moves objects that are still alive to a longer-term heap.
> 


IIRC, this idea is the famous paper "CONS Should Not CONS Its Arguments, 
Part II: Cheney on the M.T.A." by H.Baker 
http://home.pipeline.com/~hbaker1/CheneyMTA.html

-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***
_______________________________________________
Cminusminus mailing list
[email protected]
https://cminusminus.org/mailman/listinfo/cminusminus

Reply via email to