lua-users home
lua-l archive

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

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

-----Original Message-----
[] 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


> a() is referring to the anonymous function "function return b() end"
> is different to both a and b