Re: Can a Lua module find out whether it is being required or dofiled?
[
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: 2015年9月23日 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