lua-users home
lua-l archive

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

This is certainly the cleanest proposal I've seen for essentially preserving existing Lua semantics while rather thoroughly deprecating setfenv and getfenv. There were appeals to the stack-based environments thought experiment, but it distinctly did not preserve Lua's semantics and the initial "in env do .. end" in 5.2 seemed to promise things other than what it delivered (leading to things like the stack-based scopes thought experiment).

I've outlined my concerns (linting, binary function transfer) elsewhere.

Here I'll just add one other plus for this proposal which is that it seems like it should work nicely with macro systems. For example:

	Module( ... ) < module code > end


	do local _ENV = module( ... ); < module code > end

A bit tricky to write with token filters, but then so are a number of things that need to be syntactically aware, but not complicated in what it needs to produce.

(One plus on the linting front is that this change might make it easier for a linter to distinguish between global references outside the module scope and global references inside the module scope.)