lua-users home
lua-l archive

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




On Mon, Jun 4, 2018 at 1:54 PM, Hugo Musso Gualandi <hgualandi@inf.puc-rio.br> wrote:

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.


That... is persuasive.  I had worked out the simple ternaries but didn't get as far as this case. 

Ah well.  `nil or false` could still be nil, but to no remaining advantage.