[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Stack Overflow if Library is named taboo.so
- From: David Heiko Kolf <david@...>
- Date: Fri, 31 May 2013 17:18:01 +0200
Leo Razoumov wrote:
> Isn't require supposed to set package.loaded[modname] to some true
> value *before* it executes the module chunk to prevent a possibility
> of an infinite recursion? If it is not the case and require can cause
> an infinite recursion then it is a bug in Lua module system.
> Requiring modules can produce cycles (directly or indirectly) and a
> package loader should be prepared to handle this possibility.
The old "module" function did that, it created a module table and set
package.loaded[modname] right at the start of the module.
Without the "module" function you would have to do it yourself:
local M = {}
package.loaded[...] = M
-- implement the module, cyclic requirements are now valid.
return M
Best regards,
David Kolf