[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Tailcall
- From: Jay Carlson <nop@...>
- Date: Wed, 26 Dec 2001 10:10:10 -0500
On Wednesday, December 26, 2001, at 06:55 AM, John D. Ramsdell wrote:
The problem is that people have an erroneous mental model of
computation in which invoking every procedures involves pushing
arguments on a stack, saving a return address, and then jumping to the
body of the procedure. This is not how a tail call works. There is
no need to put a return address on the stack.
This mental model of computation is correct for most language
implementations, and what's more, most languages are taught this way.
("Hi, my name is Jay, and I was a BASIC programmer." "Hi, Jay.")
A significant audience for Lua is the casual programmer. We're both
highly appreciative of how people with any kind of procedural
programming experience can pretty much guess how to write small bits of
Lua code, given suitable examples. So breaking the expectations of
casual users is not something to be done lightly.
On the other hand, the two places people will encounter this is in
stack-introspective code (like MOO's callers(), which mostly is used to
talk about the most immediate caller) and in stack dumps ("how the hell
did the code get *there*??"). So it's not something that the *really*
casual user will run into.
If you misrepresent the concept of a tail call, you will produce
confusing in error messages. Treat tail calls as gotos, and error
messages will enlighten users.
In the context of Lua, it bothers me to have such an important
distinction made solely by statement position. Would treturn or tail
statements help?
Jay