[erlang-questions] erlang-questions Digest, Vol 244, Issue 8

Jim jim.rosenblum@REDACTED
Sat Nov 21 16:55:27 CET 2015


Perfect - that fixed my head. Thanks.

Date: Fri, 20 Nov 2015 22:16:52 -0800
From: Kenneth Lakin <kennethlakin@REDACTED>
To: erlang-questions@REDACTED
Subject: Re: [erlang-questions] guard clause oddity, maybe bug (in my
   brain)?
Message-ID: <56500C54.5060007@REDACTED>
Content-Type: text/plain; charset="windows-1252"

This seems a sensible way to look at it:

1> false andalso false orelse true.
true
2> ((false andalso false) orelse true).
true
3> (false andalso (false orelse true)).
false

andalso and orelse are described in the docs as

Expr1 orelse Expr2
Expr1 andalso Expr2

You *have* to have two expressions for a given andalso/orelse, so you
read expression 1 up there from left to right.
First evaluate
false andalso false (which is -obviously- false, and becomes the Expr1
of the next expression)
Then evalutate
false orelse true (which is true)

Does that make sense?

Sent from my iPad

> On Nov 21, 2015, at 6:00 AM, erlang-questions-request@REDACTED wrote:
> 
> Date: Fri, 20 Nov 2015 22:16:52 -0800
> From: Kenneth Lakin <kennethlakin@REDACTED>
> To: erlang-questions@REDACTED
> Subject: Re: [erlang-questions] guard clause oddity, maybe bug (in my
>    brain)?
> Message-ID: <56500C54.5060007@REDACTED>
> Content-Type: text/plain; charset="windows-1252"
> 
>> On 11/20/2015 08:27 PM, Jim wrote:
>> 
>> Thank you both, I guess I don't  fully understand the associative and precedence of these operators.
> 
> This seems a sensible way to look at it:
> 
> 1> false andalso false orelse true.
> true
> 2> ((false andalso false) orelse true).
> true
> 3> (false andalso (false orelse true)).
> false
> 
> andalso and orelse are described in the docs as
> 
> Expr1 orelse Expr2
> Expr1 andalso Expr2
> 
> You *have* to have two expressions for a given andalso/orelse, so you
> read expression 1 up there from left to right.
> First evaluate
> false andalso false (which is -obviously- false, and becomes the Expr1
> of the next expression)
> Then evalutate
> false orelse true (which is true)
> 
> Does that make sense?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20151121/27c459ce/attachment.htm>


More information about the erlang-questions mailing list