tail calls, continuations, ...

tail calls, continuations, ...

Post by cr8819 » Tue, 04 Nov 2003 10:33:59

I added tail call optimization now.
it is a bit messy, but as far as I can tell it is working.

I am using *** olines, my teqnique is:
in the context info I have a few fields that can be used to pass a function
and args to a higher level applys.
each apply exists as a loop which continuously applies a function to
arguments until there is no longer a function (none was put into tail
position by the last call...).
an "apply level" is used to note how many levels of apply there are, if this
is >0 when apply is called then the function and args are put in the tail
slot and the apply returns (which returns through the last forms into the
apply that called them).

I have to save/restore the apply level when entering/exiting frames,
otherwise the tail call mecanism doesn't work right...

as for continuations:
these may be more work. I may need to copy the stack (eg: by setting an
"entry mark" on the effective "top of stack" and copying until the current
end of the stack).
this may pose problems with threads, a fix may be to adjust the versions of
"ebp" in the stack if loading to a different address, but there may be yet
other problems lurking with this (eg: if one calls through a more normal c
function there is risk of it's pointers being messed up or such in some

I have little idea of the relative speed at present between my compiled and
interpreted code though, but I figure the compiled code is probably

1. TAIL (optimised tail call)

2. Tail Call Optimization (Tail Recursion)

I did some googling to find out if Ruby supports tail call optimization,
as I wanted to write tail-recursive functions. All posts I found
indicated that 1.9 supports this, but it is not enabled by default.
However, all those posts were about two years old, so I'm wondering what
is the current situation: do I still need to upgrade to 1.9 to get that
capability? Or is there something in 1.8 I can enable?

Posted via http://www.yqcomputer.com/

3. Threaded interpreter with aggressige tail-call optimization of virtual calls

4. Tail padding in base classes vs. tail padding in class members.

5. Specification of combination continuations [was Exploring continuations II]

6. About Continuation's continuation

7. Tail-call optimisation

8. tail call optimization problem

9. Tail-call optimization for mutual recursion

10. Tail call ``optimization''

11. tail call elimination

12. call-with-current-continuation and dynamic-wind

13. Call for Papers: Continuations Workshop

14. Is it important to try to write tail calls?

15. tail method calls