proper tail calls

Brendan Eich brendan at mozilla.org
Mon Jan 21 10:09:37 PST 2008


On Jan 21, 2008, at 9:08 AM, Peter Michaux wrote:

>> Proper tails calls are not an optimization; they certainly do change
>> semantics, insofar as you can't write certain programs without them
>> being guaranteed.
>
> I've been trying to find out how they are not an optimization. I
> haven't read anyone else that thinks they are not an optimization but
> I have read other people refer to them as an optimization.

Read more, then :-/. The Scheme and Pre-Scheme histories are  
interesting (in Pre-Scheme you used GOTO for a tail call -- explicit  
syntax I favor for ES4).

See, for instance, Anton van Straaten's fine comment in the same LtU  
post I cited:

http://lambda-the-ultimate.org/node/472#comment-3568

and especially:

http://lambda-the-ultimate.org/node/472#comment-3549

Quote:

"The ironic thing is that we're talking about a bug whose presence in  
the language implementation, and in people's minds, makes it  
difficult to detect that it is a bug. They don't think it's a bug,  
because they "know" recursion is unnatural and even dangerous — but  
the only reason they "know" that, is because their language  
implementation has a bug which makes it so. It's a recursive bug,  
which is particularly difficult to detect when one makes a habit of  
avoiding recursion..."

> I think
> that from an application programmers point of view they are an
> optimization since the same program will run without proper tail calls
> if the computer has infinite resources.

And if my mother had wheels, she'd be a trolley-car. Meanwhile, back  
in reality, no computer has infinite resources, and as you pointed  
out to Igor, making "TCO" an option makes it useless on the web --  
browsers have different, or no, stack quotas or redzoning. Semantics  
are not about the meanings of programs assuming infinite resources.

> Following one of those links leads to a wiki and the wiki has the
> following page which discusses proper tail calls as an optimization in
> the language
>
> http://c2.com/cgi/wiki?TailCallOptimization

Yes, it' s a common TLA but citing one use of it doesn't settle the  
debate. Please read more.

/be




More information about the Es4-discuss mailing list