lua-users home
lua-l archive

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


Thanke you. That clear up much to me. If I understood correctly, it opens
some kind of a way for "hidden" communication via shared upvalue for
functions that have gone out of scope.
One thing, that remains unclear to me: when the function IS in scope, it can
access through its upvalue the local of the enclosing scope, that is
allocated on the enclosing function's stack, I suppose. When the inner
function is called out of scope it should access this private area you
mentioned though the same upvalue. Does this mean, that the VM code is
somehow altered for the function that goes out of scope?

----- Original Message -----
From: "Wim Couwenberg" <w.couwenberg@chello.nl>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Sunday, June 01, 2003 6:57 PM
Subject: Re: Lua5 local scoping


> > What I mean is this: are this variables accessed from inner function
> > are in fact upvalues, that got rid of %? And what about old upvalues?
> > Are they still available for backward compatibility?
>
> Yes, it is an upvalue.  The %-syntax is no longer supported.  The good
part
> is that upvalues are now mutable (so you can assign to an upvalue) and can
> reference locals in _any_ enclosing scope.  As long as the local is still
in
> scope (in its defining scope) it will actually be changed by assigning to
a
> corresponding upvalue.  When the local variable goes out of scope, any
> closure that referred to it will be "closed", i.e. the local value will be
> copied over from the stack into a private structure.  It remains mutable
and
> is still shared among all closures using that same upvalue.  So from the
> closure's viewpoint, nothing changes after it is closed.
>
> Upvalues to globals are (in my understanding) no longer supported.
>
> Bye,
> Wim
>
>
>