lua-users home
lua-l archive

Re: from: Lua Module Function Critiqued

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


Am 09.10.2013 08:50 schröbte steve donovan:
On Wed, Oct 9, 2013 at 3:02 AM, Tom N Harris <telliamed@whoopdedo.org> wrote:
The module function is mutating the first upvalue of the calling function
without regard to whether it is the _ENV table.
The 5.2 compat module is indeed too simplistic
But it works reliably for the most common use-case (defining a single module in a require'd file) even if dealing with stripped byte-code ...
(Multiple modules in a single file don't work out of the box, though).
I found this out when trying to pack multiple modules into a single
Lua file.
A `local _ENV = _ENV` before, and an `_ENV = _ENV` at the top of the wrapping function should take care of that problem ...
Philipp

AltStyle によって変換されたページ (->オリジナル) /