[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua registry, environment, and threads.
- From: steve donovan <steve.j.donovan@...>
- Date: Tue, 12 Jan 2010 12:12:38 +0200
On Tue, Jan 12, 2010 at 11:00 AM, Juris Kalnins <juris@mt.lv> wrote:
> do ctx.a=1
> do
> local prev_a = ctx.a
> ctx.a = 2
> g(ctx)
> ctx.a = prev_a
> end
> end
>
>...
> When writing parser or GUI code, there is a lot of such 'ctx' passing and
> value saving.
> Dynamic scoping makes writing such code very natural.
True, but also less explicit. It's easier to analyze explicit code,
like above we can see that exceptions will leave the environment
changed, etc.
It makes life more tricky (by making variable lookup more
complicated), for some convenience.
steve d.
PS. How about doing a _G + metatable + __index trick? That could work.
- References:
- Re: Lua registry, environment, and threads., Christian Tellefsen
- Re: Lua registry, environment, and threads., Roberto Ierusalimschy
- Re: Lua registry, environment, and threads., Leo Razoumov
- Re: Lua registry, environment, and threads., Petite Abeille
- Re: Lua registry, environment, and threads., Paul Moore
- Re: Lua registry, environment, and threads., Petite Abeille
- Re: Lua registry, environment, and threads., Juris Kalnins
- Re: Lua registry, environment, and threads., Sean Conner
- Re: Lua registry, environment, and threads., Juris Kalnins
- Re: Lua registry, environment, and threads., Juris Kalnins