lua-users home
lua-l archive

Re: Modules with standalone main program

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


On Feb 24, 2018, at 6:30 AM, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
>> if ... then
>> print("I was included as a module")
>> return {}
>> end
>> print("I was executed as a program")
> 
> Try lua mod.lua 1 2 3 .
> 
As long as the command is NOT mod.lua mod 1 2 3,
I can test for required with select(1, ...) == 'mod', or simply (...) = "mod"
see http://lua-users.org/wiki/FloatSumFast

AltStyle によって変換されたページ (->オリジナル) /