lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I've had trouble finding the source of errors before when functions
return the result of calling another. Its bad enough
I've started to wonder whether writing code like:

   return other()

is poor lua idiom, and this would be better:

   local _ = other()
   return _

I'm wondering if lua could work a bit harder to preserve the names of
functions that error, though I recognise that it
is doing something nice with tail-calls that allows recursion. It just
seems to cause debuggability problems when
recursion isn't happening.

See below for an example. Its all one line, but basically errors don't
know where to point.

Cheers,
Sam


% lua -e "function bug() (nil)() end function this() return bug() end this()"
lua: (command line):1: attempt to call a nil value
stack traceback:
        (command line):1: in function <(command line):1>
        (tail call): ?
        (command line):1: in main chunk
        [C]: ?
% lua -e "function bug() (nil)() end function this() _=bug() return _
end this()"
lua: (command line):1: attempt to call a nil value
stack traceback:
        (command line):1: in function 'bug'
        (command line):1: in function 'this'
        (command line):1: in main chunk
        [C]: ?