lua-users home
lua-l archive

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


On Thursday, June 5th, 2014 at 5:56AM, Coroutines wrote:
> 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.

And in Ruby, you can do :operator, for example:

        irb(main):002:0> (1..10).reduce(:*)
        => 3628800

After looking at these and thinking more about it, I would probably prefer
to trade concise for explicit and use Python's operator.mul. Lua's
explicitness is one of the reasons I prefer it to Ruby now. YMMV
obviously.
-- 
We have not been faced with the need to satisfy someone else's
requirements, and for this freedom we are grateful.
    Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System