[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Can a Lua module find out whether it is being required or dofiled?
- From: Jerome Vuarand <jerome.vuarand@...>
- Date: Wed, 23 Sep 2015 14:24:22 +0100
2015-09-23 13:58 GMT+01:00 Dirk Laurie <dirk.laurie@gmail.com>:
> In a program, one can say
>
> mymod = require "mymod"
>
> or
>
> mymod = dofile "mymod.lua"
>
> Is there any way that the code of "mymod.lua" can distinguish
> between these?
Yes:
- require will pass the module name to the file chunk as argument
- dofile doesn't pass any argument