[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index] - Subject: Re: What are the benefits of _ENV?
- From: David Manura <dm.lua@...>
- Date: Wed, 16 Jun 2010 21:19:57 -0400
On Tue, Jun 15, 2010 at 11:29 AM, GrayFace <sergroj@mail.ru> wrote: > ...I'd like to ask what are the benefits of _ENV? In summary: The environment table is no longer a global variable (_G) nor a special variable attached to each function and accessed with special functions (getfenv/setfenv) that also have special privileges to reach into the call stack. Rather, it is a lexical variable (a "local _ENV") accessed just like any other lexical variable. Scoping of environments between nested functions is now determined statically by simple lexical scoping rules rather than at run-time, thereby simplifying static analysis. The concept of globals is also eliminated from VM, so GETGLOBAL/SETGLOBAL opcodes are replaced with more general GETTABUP/SETTABUP opcodes, which are similar to GETTABLE/SETTABLE but accept upvalue indices and apply not just to environments.