proper tail calls

Maciej Stachowiak mjs at apple.com
Mon Jan 21 20:12:06 PST 2008


On Jan 18, 2008, at 10:49 PM, Brendan Eich wrote:

>
> "If, in order make the presence of an explicit form convenient, we  
> have to add sugar for it as an additional form of expression-closure  
> -- "goto call-expr()" means "{goto call-expr();} -- I don't think  
> it's the end of the world. I do think, at present, we're meandering  
> aimlessly towards a system that claims to provide a way to make tail  
> calls, but in which nobody can ever figure out where or when they're  
> actually getting tail calls. I don't think it'll be useful to ship  
> such a language."

Is "goto" the only option being considered for how to identify tail  
position? It seems to me this could easily be confused with what  
"goto" means in languages like C, Pascal or C#. "return" might be a  
good choice of syntax if it weren't for the implicit conversion  
problem. How about something like "tailcall" or "tailreturn".


Here is another thing I don't understand: if goto must flag runtime  
errors in cases where otherwise implicit type conversion would occur,  
then does that not itself break proper tail recursion (something has  
to hang around to do the typecheck on the actually returned type)? Or  
is the intent that it throws a runtime error before the call if it  
can't statically prove that return types match? Does that mean you can  
never goto an untyped function from one with a declared return type?

Regards,
Maciej




More information about the Es4-discuss mailing list