[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Function Addresses?
- From: "Paul Hudson" <phudson@...>
- Date: Tue, 13 Jun 2006 16:29:00 +0100
My guess (not having looked at the C implementation) is that it's probably
easier to create a new closure on each call than work out that there's no
need in this particular case.
In general, you do need a different closure on each call, of course.
function a()
local i = 0;
return function () i = i + 1; return i; end
end
-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of King, Mike
Sent: 13 June 2006 16:23
To: Lua list
Subject: RE: Function Addresses?
Why would it be desired to have a new anonymous function created for
each call?
function a()
return function () end
end
print(a())
print(a())
> a() is referring to the anonymous function "function return b() end"
which
> is different to both a and b