lua-users home
lua-l archive

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


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)