[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Assign(...)()
- From: Robert Raschke <r.raschke@...>
- Date: Fri, 19 Mar 2004 15:19:57 +0000
On Fri, 19 Mar 2004 around 15:59, you wrote:
> When 2 bracket pairs ()() have to be used?
> I don't understand some cases in which after the 1st pair (containing
> arguments) an empty second pair has to be given.
Functions can return functions. Some very contrived examples:
> mkAdder = function (x)
>> return function (y) return x + y end
> add5 = mkAdder(5)
> mkCounter = function (x)
>> local i = x - 1
>> return function () i = i + 1; return i end
> counter = mkCounter(42)
Not very useful examples I know, I'm sorry.
I guess writing code that ends up stating f(x)() is a bit odd.