[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: "dynamic" closures
- From: Patrick Donnelly <batrick@...>
- Date: Mon, 30 Nov 2009 06:21:55 -0500
On Mon, Nov 30, 2009 at 6:12 AM, spir <denis.spir@free.fr> wrote:
> x = 1
> function f()
> n = 1
> function g(a)
> print (x + n + a)
> end
> return g
> end
>
> g= f()
> g(1) --> 3
>
> x = 2
> g(1) --> 4
I believe you meant to use locals here:
local x = 1
function f()
local n = 1
function g(a)
print (x + n + a)
end
return g
end
?
--
-Patrick Donnelly
"Let all men know thee, but no man know thee thoroughly: Men freely
ford that see the shallows."
- Benjamin Franklin