[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: false and nil
- From: dyngeccetor8 <dyngeccetor8@...>
- Date: Wed, 6 Jun 2018 01:37:40 +0300
On 06/05/2018 11:03 AM, Viacheslav Usov wrote:
> On Tue, Jun 5, 2018 at 3:35 AM, dyngeccetor8 <dyngeccetor8@disroot.org>
> wrote:
>
>> Current behavior of "and" and "or" operators is equivalent to following
> Lua-like functions.
>
> The behaviour is documented in section 3.4.5, and the essential part of it
> is the "short-circuit evaluation; that is, the second operand is evaluated
> only if necessary". Your explanation is far more complicated than that and
> is technically incomplete and/or inconsistent anyway.
Section 3.4.5 describes it nicely indeed:
The negation operator "not" always returns "false" or "true". The
conjunction operator "and" returns its first argument if this value
is "false" or "nil"; otherwise, and returns its second argument. The
disjunction operator "or" returns its first argument if this value
is different from "nil" and "false"; otherwise, "or" returns its
second argument. Both "and" and "or" use short-circuit evaluation;
that is, the second operand is evaluated only if necessary.
I've showed how this logic may be implemented via Lua functions. Yes,
that illustration is technically incomplete (for better expression
power). But why it is inconsistent? From my view that functions is
logically correct.
-- Martin