[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua5.0 new "For" question
- From: Eero Pajarre <epajarre@...>
- Date: Sun, 22 Dec 2002 22:05:59 +0200
Björn De Meyer wrote:
you can still say
f = function() return %x end
But that one seems to behave exactly the same as when not
using the %, namely it will print 456. Because of the
lexical scoping the x in the anonymous function is the
local x of fie(). The value of x is only "taken"
when f() is called.
Looks like % is just accepted for compatibility,
but otherwise ignored (except the global upvalue message)
So your example creates a closure with or without the "%".
f = function() return x end --global f
fie() -- call function which creates function f
print(f()) -- prints 123
print(f()) -- still prints 123