[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Another puzzle for you all, with upvalues
- From: Roberto Ierusalimschy <roberto@...>
- Date: Wed, 20 Oct 1999 14:22:09 -0200
> Is that expected behavior too, or am I just trying to write so sick
> and nasty code ?? :)
Well, it is expected behavior. Upvalues apply only to variables, not to
fields. When you write %t.a, the binding is (%t).a, and not %(t.a); so,
only the t is frozen, not the field value. If you really want to run
that code, you need a temporary variable:
t.a = function(s)
print(s)
end
local ta = t.a
t.a = function(s)
print(s)
%ta(s)
end
-- Roberto