lua-users home
lua-l archive

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


Am 19.11.2013 01:48 schröbte Coda Highland:
On Mon, Nov 18, 2013 at 4:40 PM, Philipp Janda <siffiejoe@gmx.net> wrote:
Am 18.11.2013 22:47 schröbte Tim Hill:
— Brevity (easier to type “foo” than “some table.somefunction”)
— Performance (access to locals is faster than access to globals or table
values with string keys)
+ Making a module immune to changes in the global environment
+ Providing easy access to globals when you intend to replace `_ENV` (or use
`module`/`setfenv`)
+ Documenting a module's/file's dependencies
+ Asserting that the module's/file's dependencies are there at load time

These all can be done with _ENV; local isn't necessary for them.

`_ENV` *is* a local (or an upvalue), so yes, of course this also works with another level of indirection.


/s/ Adam


Philipp