[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: local "module" pattern without module [was Re: [ANN] SLAXML - pure Lua, robust-ish, SAX-like streaming XML processor]
- From: Andrew Starks <andrew.starks@...>
- Date: Mon, 18 Feb 2013 22:00:27 -0600
On Mon, Feb 18, 2013 at 9:45 PM, Gavin Kistner <phrogz@me.com> wrote:
> Thank you very much for your contributions. I'd be interested in your response to my current solution as described here:
> http://stackoverflow.com/questions/14942472/create-suite-of-interdependent-lua-files-without-affecting-the-global-namespace
>
>
I think it's solid, but it's also deprecated in 5.2. My understanding
of the reasons were that getfenv violated CSCI's agreement that scope
should be sacred. Lua 5.2 exchanged this magic (hid it, actually) for
a clever twist (different than magic), which was _ENV. Since _ENV
can't be applied to a function that was already defined, it doesn't
really solve all of your problems.
I mean it *could*, but you're back to passing _ENV into the submodule
and then you may as well do it my way, so that you can also benefit
from the goodness and bounty that the '_ENV = require"mymodule._ENV"'
construct provides: a common module platform from which to work and
protection for the user's global table, explicitly.
But, you do get huge bonus points for cleverness, and I mean that with
all sincerity. It took me a good bit of time, just staring at it,
before I understood it. AND, I didn't feel like I needed *another*
shower. :)
-Andrew
- References:
- Re: local "module" pattern without module [was Re: [ANN] SLAXML - pure Lua, robust-ish, SAX-like streaming XML processor], Gavin Kistner
- Re: local "module" pattern without module [was Re: [ANN] SLAXML - pure Lua, robust-ish, SAX-like streaming XML processor], Gavin Kistner
- Re: local "module" pattern without module [was Re: [ANN] SLAXML - pure Lua, robust-ish, SAX-like streaming XML processor], Andrew Starks
- Re: local "module" pattern without module [was Re: [ANN] SLAXML - pure Lua, robust-ish, SAX-like streaming XML processor], Gavin Kistner