[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: module() with _ENV
- From: "Stuart P. Bentley" <stuart@...>
- Date: Tue, 30 Mar 2010 18:47:34 -0600
With the proposed _ENV environment design for 5.2 that would reassign
setfenv/getfenv to the debug library, would it also make sense to change
the design of module() to return the table to use as the environment,
rather than actually having it change the environment? This way, you could
replicate the old use of module with the only slightly different statement
"_ENV = module(...)" without having to "bend the rules" of the language
(that non-debug functions can't change the environment of their callers),
as well as allowing other uses of module(...) for its semantics handling
(its table reuse/creation rules)- so, if you prefer to explicitly put
everything inside your module's table, you could still make this table
with "local mymod = module(...)", and it would handle all the complexities
of creating the table (re-using any existing table in the working
environment, creating it otherwise, and placing it in package.loaded).