lua-users home
lua-l archive

Re: Lua registry, environment, and threads.

[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

AltStyle によって変換されたページ (->オリジナル) /