Tip of the day

Richard Carlsson <>
Wed Aug 18 13:18:24 CEST 2004

On Wed, 18 Aug 2004, Thomas Lindgren wrote:

> > A question popped out when reading this: can the
> > stack really be traversed
> > when we are using tail-call optimization?Or more
> > precisely, would it be
> > menaingful to traverse it in the presence of
> > tail-calls?
> [...]
> "Ignoring the problem" is probably the easiest one to
> get going :-)

And if you look at the stack traces from exceptions in
Erlang/OTP you will see that this is what happens today.,
i.e., tail calls are simply missing from the trace. (I'm
not sure what the debugger does, though - it has its own
interpreter and could in principle remember tail calls.)

Also, the next-to-last function is usually missing from
the stack trace, because it is not always stored on the
stack, but kept in an emulator register when possible,
and cannot be relied on to hold current information when
an exception occurs (which usually happens inside a
built-in function).


Richard Carlsson ()   (This space intentionally left blank.)
E-mail: 	WWW: http://user.it.uu.se/~richardc/
 "Having users is like optimization: the wise course is to delay it."
   -- Paul Graham

More information about the erlang-questions mailing list