Guards and side effects
Fri Mar 11 12:32:20 CET 2005
On 2005-03-11 at 11:28:05 (+0100), Vlad Dumitrescu wrote:
> From: "Thomas Johnsson XA (LN/EAB)" <>
> > There are many opportunities for the programmer to shoot him/herself in the
> > but to hold the programmer in strict harness in this particular corner of the
> > language, and nowhere else, I find that misguided.
> Good point, I think. The language proper should not be restricted by what are
> mostly implementation/optimization issues. And extra power might open
> possibilities that now are closed.
> However, Erlang has a very pragmatic background. If the extra power means a
> noticeable slowdown in applications that don't use that power, it's not going to
> be easy to convince users it's good idea.
Well the extra power is just "syntactic sugar" for something that is
already possible in Erlang. Not being able to express some condition
in guards just forces one to use another approach which might look
In fact I think it would be really possible to introduce the extension
(using arbitrary boolean expressions in guards) using
the parse_transform mechanism for at least functions and if
expressions (preserving the semantics of a receive statement I think is
very difficult). It is just some work and might reduce the performance
compared to an implementation in the compiler (of the generated code).
Performance loss for old code should not occur, because a guard
expression using only expressions allowed today in guards can be
compiled as it is now.
More information about the erlang-questions