lua-users home
lua-l archive

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


On Feb 24, 2018, at 6:03 PM, Paul K <paul@zerobrane.com> wrote:

> Hi Dirk,
> 
>> I.e. "doflile" is treated just like "require'.
>> I want "require" to return and all other ways of running the file to continue.
> 
> It wasn't clear from your question that you want to distinguish
> between require and dofile calls, but it shouldn't be too difficult to
> add:
> 
> if pcall(debug.getlocal, 4, 1) then
>  if select('#', ...) == 0 then
>    print("dofile package")
>  else
>    print("require package")
>  end
> else
>  print("main script")
> end
> 
> Paul.

figured out why dofile have zero argument.

what if later versions of dofile allow optional command-line args ?
what if user use this form: loadfile "mod.lua" "arg" ?

it will then goto require branch.