[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Random thought: short lambda syntax (no patching required!)
- From: Geoff Leyland <geoff_leyland@...>
- Date: Mon, 26 May 2014 21:02:22 +1200
On 26/05/2014, at 8:53 pm, Xavier Wang <weasley.wx@gmail.com> wrote:
> What about just like C++'s lambda syntax?
>
> table.sort(t, _1 > _2)
>
> _1 and _2 has a metatable to generate syntax tree on-the-fly. and when __call is called, the syntax tree is translated into lua function.
Unfortunately for this particular case, relational metamethods only support returning a boolean. You can’t build expressions with them (but you can with the arithmetic operators)