[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: default stack trace function
- From: Mark Hamburg <mhamburg@...>
- Date: Wed, 29 Sep 2004 21:42:27 -0700
Were you look for tail-call optimization and surprised not to see it? Try:
p2 = function()
p1 = function()
Without the return, the function needs to reduce the number of results to
zero after making the call, so it isn't done and hence can't use a tail
on 9/29/04 6:16 AM, Frederico Rodrigues Abraham at firstname.lastname@example.org
> I noticed something that seems strange to me when using the error
> function with an error level parameter.
> Consider the following piece of code:
> p3 = function()
> error("the error",3)
> p2 = function()
> p1 = function()
> luaf = function(d)
> return "the result"
> -- END OF CODE
> Running the lua 5 interpreter with this file gives the following stack trace:
> lua5: stacktrace.lua:10: the error
> stack traceback:
> [C]: in function `error'
> stacktrace.lua:2: in function `p3'
> stacktrace.lua:6: in function `p2'
> stacktrace.lua:10: in function `p1'
> stacktrace.lua:15: in function `luaf'
> stacktrace.lua:19: in main chunk
> [C]: ?
> The line where the error happened seems correct. (line 10, the call to
> p2() in p1 body)
> Shouldn't the stack trace omit the lines for error levels 1 and 2?
> (line 2 and 6, respectively)
> -- Fred