lua-users home
lua-l archive

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

Luiz Henrique de Figueiredo <> wrote:

>>Is there a (preferred) way to determine inside a script what file it was
>>loaded from? 
>Yes, use "getinfo(1)". This returns a table.  The "source" field contains
>the file name (after a '@'). See below:
>The manual says that "getinfo" is part of the debug API and that you should
>avoid it. I think that using it for information purposes is ok (ie., avoid
>"setlocal"!). Perhaps we can change the wording in the manual.

Thanks, this is exactly the answer I was hoping for.  I have not looked
much at getinfo, because I did not want to rely on a function which is
part of a library one is not supposed to load in normal use.  You could
consider splitting of those parts of getinfo which you consider really
safe and useful in general, and put it in a separate function in the
baselib some day (or keep the name, and move the "bad" parts to another one).