[erlang-questions] Re: If one guard expression in the guard fails, are the remaining expressions still evaluated?
Lukas Larsson
lukas.larsson@REDACTED
Sun Feb 20 17:11:27 CET 2011
The second sentance refers to the fact that if something in a guard throws an exception (i.e. fails) then the entire guard will fail. It does not refer to a guard statement returning false. If a guard statement does return false it will not continue executing if , are used, but it will of course do so if ; are used in the guard. You could of course skip the usage of , and ; and use andalso and orelse if you want control yourself of what will happen.
Lukas
----- Original Message -----
From: "Alexey Romanov" <alexey.v.romanov@REDACTED>
To: "Steve Davis" <steven.charles.davis@REDACTED>
Cc: erlang-questions@REDACTED
Sent: Sunday, February 20, 2011 3:46:27 PM GMT +01:00 Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna
Subject: Re: [erlang-questions] Re: If one guard expression in the guard fails, are the remaining expressions still evaluated?
I've asked precisely because reading section 7.24 didn't clarify it
for me. The relevant sentences are "The guard is true if all guard
expressions evaluate to true." and "If an arithmetic expression, a
boolean expression, a short-circuit expression, or a call to a guard
BIF fails (because of invalid arguments), the entire guard fails." The
first sentence suggests to me that all expressions are evaluated; the
second that expressions after the one that failed aren't. But both
aren't explicit.
I know about short-circuit expressions, but 7.14 doesn't say anything
about evaluation of guards (unsurprisingly).
Yours, Alexey Romanov
On Sun, Feb 20, 2011 at 4:31 PM, Steve Davis
<steven.charles.davis@REDACTED> wrote:
>
> Take a look at section 7.14 (Short-Circuit Expressions) as well as 7.24 of
> that chapter. It should clarify.
>
> /s
>
> --
> View this message in context: http://erlang.2086793.n4.nabble.com/If-one-guard-expression-in-the-guard-fails-are-the-remaining-expressions-still-evaluated-tp3315062p3315110.html
> Sent from the Erlang Questions mailing list archive at Nabble.com.
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>
________________________________________________________________
erlang-questions (at) erlang.org mailing list.
See http://www.erlang.org/faq.html
To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
More information about the erlang-questions
mailing list