lua-users home
lua-l archive

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


Tracebacks (and the debug API) show the name of the variable that
referenced the function.

It depends. With Lua 5.3, I tried to set `string.gsub` to a value `x` and
test some things with it. Invalid argument and other errors gave an
error with the function `x`, but the traceback showed it was an error
with the function `string.gsub`. So, the function does have a name
associated with it, but it does also include the name used when
referencing that function. The traceback - at least with Lua 5.3.1 -
will show that the error happens when the value with the associated
name is called, but it shows that the error is in the function with the
original name.

I've attached an example script if you want more of a reference.

On Sat, Oct 21, 2017 at 7:09 PM Dibyendu Majumdar <mobile@majumdar.org.uk> wrote:
Hi Eduardo,

On 22 October 2017 at 00:50, Eduardo Ochs <eduardoochs@gmail.com> wrote:
>> Functions in Lua are values stored in variables; in particular functions do not have names
>
> Tracebacks can sometimes determine, or guess, function names. I think
> I never saw a description in english of the algorithm that is used for
> that, though...
>

Tracebacks (and the debug API) show the name of the variable that
referenced the function.

Regards

--
--
Ryan | Charles <vandor2012@gmail.com>
Software Developer / System Administrator
https://hashbang.sh
x = string.gsub
x("arg error")