lua-users home
lua-l archive

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


2010/1/9 Cosmin Apreutesei <cosmin.apreutesei@gmail.com>:
>> Actually, I'd love to hear the official "motivation" behind this feature.
>> New syntax constructs are rarely introduced in Lua, and this one was
>> dropped like a bomb, without any warning.
>
> Regardless of motivation, there's a technical limitation of current
> function environments that lexical environments are solving, and it
> can only be solved by introducing new syntax (it's gotta be a lexical
> thing). Currently you can't have the same function in two environments
> at the same time.

Well you can. I guess you mean a function can't have 2 environments at
the same time. My understanding is that it still can't.

"in env do <code> end" is (I believe) simply equivalent to:
setfenv(function () <code> end, env)()

Matthew