lua-users home
lua-l archive

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


2017-10-12 0:17 GMT+02:00 Antonio Scuri <antonio.scuri@gmail.com>:

>   In lua_Debug documentation, "source" description states that if the
> function was defined in a string then "source" is that string.
>
>   I may misunderstood it but it seems that in this case source is the
> chunkname, not the string. If chunkname is not used, then chunkname is the
> string, which results in what is described. But if chunkname is used then
> "source" is not the string where the function was defined.
>
>   I tested in Lua 5.1, 5.2 and 5.3 and they all behave the same.

Let's quote the actual description in full.

source: the name of the chunk that created the function. If source
starts with a '@', it means that the function was defined in a file
where the file name follows the '@'. If source starts with a '=', the
remainder of its contents describe the source in a user-dependent
manner. Otherwise, the function was defined in a string where source
is that string.

You can see that the actual Lua code is a last resort, a fallback if
the user failed to take any of the opportunities to provide something
more suitable.

>   So, is there a problem in the documentation or in the debugger?

The only problem with the documentation is the expectation raised by
the word "source" and by the phrase "name of the chunk". A term more
friendly to ex-Python users would be "docstring".