views:

428

answers:

3

I've heard that trampolining is an ineffective way of implementing TCO. How does DrScheme (PLAI Scheme, technically) do it? Does it do it the 'right' way (that is, produce assembly code which directly branches to the tail call, instead of going through the stack and trampolining)?

+2  A: 

The implementors of PLT Scheme are quite active in their Google group, where you can get a quick answer from the people who write the code.

I'm not sure they read SO, though, so your best bet would probably be asking there.

Eli Bendersky
+2  A: 

Matthew Flatt, the chief implementor of MzScheme (now PLT Scheme) told me in June 2008 that at one time they compiled down to virtual-machine code, in which case it is easy to write a VM that does proper tail calls. Now, however, the system is mature enough that on x86 they use a simple JIT. In either case, there is no trampolining---the PLT Scheme guys know their business.

Norman Ramsey
+1  A: 

Trampolines are used in implementations that translate Scheme code into a target language X (C, Java, etc.) that doesn't support Proper Tail Calls. PLT Scheme employs JIT-compilation - and therefore trampolines are not needed. For the exact implementation strategy used, ask the question on the PLT mailing list.

PS: You can read more on trampolines in the various "Compile Scheme to C" papers available on ReadScheme.org.

soegaard