[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Modules with standalone main program
- From: Paul K <paul@...>
- Date: Sat, 24 Feb 2018 15:06:21 -0800
>> if pcall(debug.getlocal, 4, 1) then
> can you elaborate what 4 and 1 mean ?
It checks if there is anything in the 1st variable at the 4th level,
which would be the caller of the current module (if required) or
nothing in the case of the main script.
> how does it know we are testing mod.lua being required (or not) ?
> and not testing for something else ?
> ("mod" is never mentioned in above test)
It doesn't care about the name of the module; it only checks the stack.
> the stand-alone program might also require some other modules, which
> also might require others ... does above work all the time ?