lua-users home
lua-l archive

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


Am 18.11.2013 22:47 schröbte Tim Hill:
(top-posting as general comment…)

Isn’t this really a circular discussion? It seems to me there are two reasons for assigned a function in a table to a local:
— 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

Philipp