lua-users home
lua-l archive

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

To make the boolean operators non-commutative you would need to give up on short-circuiting evaluation. For example, consider:

    (i <= #xs and xs[i]:isgood())

If you try to evaluate the right operand when the left one is false (to check if it is nil or not) then xs[i] will evaluate to nil and trying to call the isgood method will result in a runtime error.

On Jun 4, 2018 5:44 PM, Sam Putman <> wrote:
I should add that I do understand what's happening here.

and & or aren't Abelian in general nor should be:

> = true and "boo"

It is only in the case of nil that I suggest the falsiness propagate as a nil.  There are considerable advantages in reasoning power.