lua-users home
lua-l archive

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


On Mon, Apr 14, 2014 at 8:55 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 2014-04-14 17:29 GMT+02:00 Coroutines <coroutines@gmail.com>:
>
>> If a module returns false or nil, I believe it will be loaded from the
>> file on every require().
>
> Not quite. The go/nogo test is whether there is an entry for the module
> in package.loaded.
>
> $ lua
> Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
>> package.loaded.lpeg = "bazinga"
>> lpeg = require"lpeg"
>> =lpeg
> bazinga
>

I thought it checked package.loaded.module_name for a boolean-true
value and returned that, otherwise it loaded the module (if it exists)
from the search paths, no?  If you return nil/false it'll be loaded
from the file every time?