lua-users home
lua-l archive

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


> Aha!  So, it takes a snapshot of all of the current bindings of all of
> the local variables in the lexical environment.  Sounds clear to me.
> The bindings of the variables are the values of the variables, not the
> addresses that the names point to.  I sure hope nobody's disputing that.

OK. I've been following this topic.

What is the expected output of the following snippet if the function
returned by get_function is a closure?

k = 0;

function n(x)
   k = k + 1;
   return x + 10;
end

function get_function(x, y)
     return
	     function (y)
		    z = n(x);
		 end;
end

f = get_function(100, 100);

f(100);
f(110);

print ("n called " .. k .. " times");

--
Quinn Tyler Jackson
http://members.shaw.ca/qjackson/