Debugging of Strings

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Debugging of Strings

Antonio Scuri-2
  Hi,

  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.

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

  Assuming it is just a problem in the documentation, during debug how can we retrieve the original string given the chunkname?

Thanks,
Scuri

Reply | Threaded
Open this post in threaded view
|

Re: Debugging of Strings

Dirk Laurie-2
2017-10-12 0:17 GMT+02:00 Antonio Scuri <[hidden email]>:

>   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".