[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Function Addresses?
- From: "King, Mike" <MKing@...>
- Date: Tue, 13 Jun 2006 11:37:56 -0400
> Because the function statement creates closures. Try this:
>
> function add(x)
> return function(y) return x+y end
> end
>
> add10=add(10)
> add20=add(20)
> print(add10(3),add20(3))
It makes sense now. I was thinking about how C# implements anonymous
methods. In C#, anonymous methods are just syntactic sugar; the
compiler pulls the function out and calls it.
Thanks for all of the responses!