newbie question

Matthias Lang <>
Tue May 17 14:01:40 CEST 2005


Thomas Johnsson XA \(LN/EAB\) writes:

 > There are situations where it is important that guards are fast 
 > and side effect-free (in receive, for example).
 > Conditions in if-expressions is *not* one of those places, IMHO. 
 > (Except for the usual good reasons to to program as 'functionally' 
 > as possible). Ie, there is no reason that I can see why the 
 > if-condition has to be a guard syntactically rather than an expression.
 > I just forces the programmer to write something more clumsy.

 > Or is there some light I haven't yet seen?

It's nice and simple to say 

   "No side effects in guards"

whereas it's rather painful to say

   "No side effects in guards, unless it wouldn't be messy to have
   them, for instance if there aren't very many clauses in the guard,
   especially if it's part of an if statement, but possibly also in
   a case and maybe even in a receive with for instance only four 
   clauses but definitely not in an 'if' with three clauses if they're
   complicated and hard to read, because that would be clumsy."

and even more painful to explain to the compiler and optimiser.

Matthias



More information about the erlang-questions mailing list