[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Modules with standalone main program
- From: Paul K <paul@...>
- Date: Sat, 24 Feb 2018 00:33:34 -0800
> Is there a test that allows the following logic?
Maybe this one: `if pcall(debug.getlocal, 4, 1) then return module end`?
Paul
On Sat, Feb 24, 2018 at 12:25 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> This has come up before, but I can't remember or find the answer.
>
> Is there a test that allows the following logic?
>
> ----
> if test then -- module was invoked by 'require'
> return module
> end
> -- continue with main program
> ----
>
> The best I can come up with is to insist on 'lua -i' for the
> standalone, and use os.exit if I don't want to fall back to Lua.
>