[erlang-questions] Guards syntax for multiple values

Lars-Åke Fredlund lfredlund@REDACTED
Thu Mar 28 10:00:55 CET 2019


A good analysis.

Please consider generalising the if statements (and/or finally introduce 
a cond expression) to permit arbitrary functions; the separation between 
guard functions and normal "predicate" functions has always felt very 
artificial to me when writing code. There is a reason as Mikael says to 
keep it for the receive, but in other contexts... It just hurts 
expressitivity.

/Lars-Ake


On 27/3/19 9:57, Mikael Pettersson wrote:
> Instead of focusing on syntax, people should focus on semantics.
>
> The basic problem is the very presence of so-called "guard
> expressions", as a highly restricted subset of the general set of
> expressions.  The guard expression restriction is only needed in
> receives, to ensure that the mailbox doesn't change as a side-effect
> of evaluating the pattern match + guard combination.  In other
> contexts, guards could be fully general boolean expressions -- only
> historical reasons prevent them from being so.
>
> Personally I tend to write code to dispatch on the result of
> classification functions instead of relying on complex guards.
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list