[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: false and nil
- From: James Darnley <james.darnley@...>
- Date: Thu, 7 Jun 2018 21:29:50 +0200
On 2018-06-04 23:00, Sam Putman wrote:
> On Mon, Jun 4, 2018 at 1:54 PM, Hugo Musso Gualandi
> <firstname.lastname@example.org <mailto:email@example.com>> 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
> not not value
Description: OpenPGP digital signature