On 2018年06月04日 23:00, Sam Putman wrote: > > > On Mon, Jun 4, 2018 at 1:54 PM, Hugo Musso Gualandi > <hgualandi@inf.puc-rio.br <mailto: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. This might not be directly related to your case but... If you want to turn any value into a boolean that still has the same truthiness then use this: > not not value
Attachment:
signature.asc
Description: OpenPGP digital signature