lua-users home
lua-l archive

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


> Lua 5.2 will have "lexical environments", a kind of lexical setfenv.
> The construction "in t do command end"  will execute <command> with
> all global variables being resolved in <t>.

I didn't closely follow this thread so maybe it was answered already,
but did you consider using an upvalue for the environment?

   in <identifier> do ... end

This lets you swap environments by assigning to <identifier>.  This
also covers an example of Mark Hamburg:

local c = Class()
in c do ... end

could become

in c do ... c = Class() end

Bye,
Wim