lua-users home
lua-l archive

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


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.


There is no appropriate value for package.loaded to be set to until the package code has finished executing. If require set it to some placeholder value, it would just cause errors in other portions of the application.