[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Global environment question
- From: "Jamie Rivett" <jrivett@...>
- Date: Thu, 26 Feb 2004 11:44:52 -0600
Thanks!
I just got a copy of the book and will check out the chapters you
listed.
Jamie
-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Taj Khattra
Sent: Wednesday, February 25, 2004 11:17 PM
To: Lua list
Subject: Re: Global environment question
On Wed, Feb 25, 2004 at 01:16:45PM -0600, Jamie Rivett wrote:
> I have a simple example below. It defines global a. Changes the
> global environment to a new empty table then defines global b. When I
> call
> Blah() the new global b var is not defined. I understand that Blah()
is
> in the old global table but why doesn't it inherit the environment
from
> the calling function?
the current environment inherited by the closure that is assigned to
Blah is the original global environment, since you only changed the
current environment to newgt *after* the assignment to Blah. in order
to inherit the new environment, you would need to move the closure
assignment after the call to setfenv().
chapters 14 and 15 of Roberto's book go into more details on this stuff.
-taj