[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: functions and upvalues
- From: "Wesley Smith" <wesley.hoke@...>
- Date: Thu, 31 May 2007 13:00:09 -0700
You're right. I will just have to make a table and pass it in.
On 5/31/07, Will Leshner <firstname.lastname@example.org> wrote:
On 5/31/07, Wesley Smith <email@example.com> wrote:
> What I'd like is f1's val upvalue to refer to constructor's local
> variable val. Is this possible somehow through environments?
It looks like you are expecting dynamic scoping, but I believe Lua
uses static scoping (which is actually a really good thing as upvalues
and closures wouldn't work at all with dynamic scoping).
Wikipedia appears to have a pretty good page describing the difference
between dynamic and static scope, and there's even an example they use
to compare the two that looks a lot like your example. The page in
question is here: