lua-users home
lua-l archive

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


On Sun, Dec 6, 2009 at 5:37 AM, Pierre LeMoine <yarr.luben@gmail.com> wrote:
>> A close form could already be implemented, without upvalues though:
>>
>> local f = y[[ x + y with x, y ]]
>>
>
> I think this looks rather nice actually. Doesn't seem like too much
> trouble to implement a such y-function and call it lambda or whatever
> catches one's fancy.

Oh it's not a difficult trick, can have local f = y "|x| x+y" as well.
But it does not capture upvalues, as pointed out (i.e. it cannot see
local variables in the current context) So no good for closures, but
for the little one-liners we were talking about it does fine.

This  lua-users wiki page is very relevant to the short-form discussion:

http://lua-users.org/wiki/ShortAnonymousFunctions