lua-users home
lua-l archive

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


> While I've personally always returned my modules, this would
> technically change the flow of current module definitions using
> module, which write directly to their package.loaded table. For an
> example where this semantic change would have a noticeable impact,
> imagine a package that defines only a few base functions before
> loading a helper package (which uses local base = require
> "partially_loaded_module"). With the classic "module" style, this
> would work, as the functions would be loaded from the
> partially-constructed table; with returning, it would fail, as the
> "base" package returned by "require" in the sub-package would be
> "true".

It will still possible to write that kind of module adding the extra
lines

   -- allow module 'mod' to require this one
   package.loaded[modname] = _ENV

The question is how common is the need for such different flows to
deserve a special function, or whether it is better to write this code
explicitly, only when needed, to better document what is going on.

The point is that currently 'module' supports several, maybe too many,
tricks. We think that few people need them and fewer need all of
them. So, it may be better to lay your tricks explicitly when needed
instead of assuming them all the time.

-- Roberto