lua-users home
lua-l archive

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

2014-06-05 9:18 GMT+02:00 Coroutines <>:
> On Thu, Jun 5, 2014 at 12:07 AM, steve donovan
> <> wrote:
>> sort(cities) do (x,y: string) -> int:
>>   cmp(x.len, y.len)
> On a related note, sometimes I wish Lua allowed putting an operator in
> place of where a function would be expected.  Something like:
> table.sort(some_table, <)
> I don't know how that could be made less confusing from the parsers'
> perspective, though.  I think you can do this in Haskell with \+ to
> refer to the function of the operator itself.

    table.sort(some_table, __lt)

would be immediately understandable though not pretty. I would
probably want to hide such functions from next(_ENV), though.

   setmetatable(_ENV,{__index = {__lt = ...}})