[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: a new proposal for environments
- From: Mark Hamburg <mark@...>
- Date: Fri, 26 Feb 2010 07:07:58 -0800
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
becomes:
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.)
Mark