lua-users home
lua-l archive

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

On Wed, Apr 10, 2013 at 5:44 AM, Andrew Starks <> wrote:
So, {_ENV is] mostly the same feature, but the design of the feature's interface makes the language better. These things are critically important and I know that there is a great appreciation of design, on this list. 

I must agree that it is a more elegant and transparent mechanism, and a rare case of a programming language becoming _simpler_.

However, using it for namespacing ties one to 5.2 prematurely. Like its disgraced friend module(), the argument is that modules cannot damage the global table accidently.  That's fair enough, although I've come to appreciate simple static analysis tools that make accidental globals a 'compile time' issue.  In compat mode, module() still works in 5.2, although with some limitations if you use it in functions (which happens when squishing or soaring a self-contained executable archive)  For instance, luasocket still uses module() in its Lua part, which is mostly ok, except in such an archive module() misbehaves by resetting _global_ _ENV.  I wrote a little replacement that doesn't suffer from this issue, but that's a story for another day.