lua-users home
lua-l archive

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




Am Mo., 17. Sep. 2018 um 23:44 Uhr schrieb Sean Conner <sean@conman.org>:
It was thus said that the Great Dirk Laurie once stated:
>
> Look, the notation "a<b" to mean a non-boolean is so counterintuitive, why
> not use just say "a|b" which can return whatever? Or have you used up all
> the binary operators already?

  I wrote a language in college were you could overload operators and have
them return anything.  Including "<" and ">".  Because of that, I was able
to implement a Unix shell rather easily.  Unix commands were first class
objects and they overrode "<" amd ">" to allow redirection of stdin and
stdout.

Interesting use case. I am still thinking about that and another reason why __lt / __le / __eq metamethods are converting to bool might be that the bool operators are expecting this - which brings up the point that adding an __and and __or metamethod would be useful too. This would give full control how objects should be handled when used in this context. 
I am now solving my problem with a "x: lesser (y)" callback, but this also involves adding some brackets as well. I think it would be neat if I had full control over this. Would be making describing my state machine data more concise.

Cheers,
Eike