On Aug 4, 2014, at 9:40 AM, Andrew Starks <andrew.starks@trms.com> wrote:
On Sun, Aug 3, 2014 at 2:03 PM, Tom N Harris <telliamed@whoopdedo.org> wrote:
I'll have to remember this the next time I feel the urge to write `return
value, recursive_call(...)` which isn't a tail call. Although I've
occasionally thought the VM could pull some stack manipulation tricks to make
it a tail call.
Hmm... I had to look this up. I thought that `return value, recursive_call(...)` would be a tail call. I guess it isn't, given that `return fund(args)` is the required form.
This gets into what "tail call" means, and perhaps specifically what "properly tail recursive" means. As a matter of language specification, the call to f in
function f()
return 1, f()
end
is difficult to require to be a tail call, since the return values stack will exhaust all memory regardless of whether activation records do.
You can watch Scheme fight it out here:
https://groups.csail.mit.edu/mac/ftpdir/scheme-mail/HTML/rrrs-1997/msg00048.html
Jay