Guards and side effects
Ulf Wiger (AL/EAB)
Fri Mar 11 11:08:48 CET 2005
> -----Original Message-----
> From: Thomas Johnsson XA (LN/EAB)
> Sent: den 11 mars 2005 10:35
> To: erlang-questions@REDACTED
> Subject: Guards and side effects
> (Subduing the hardcore functional programmer in me for a bit ... :-)
> I see really no compelling reason to prohibit side effects in guards,
> in fact there may well be sensible uses, for instance, communicating
> with another process to find out the value of the guard,
> consult ets tables or other data bases, call a memo function ....
I completely disagree. (-:
I would like to see a way to declare new guard expressions,
but think those guard expressions should be declarative and
fall strictly within the realm of pattern matching.
I think it is perfectly reasonable and sound to clearly
differentiate between functions that modify data (and perhaps
produce side-effects) and expressions that test the validity
of data in a side-effect free manner.
The purpose of user-defined guards should be to allow for
more expressive (and/or more intuitive) match expressions,
not to introduce new semantics.
More information about the erlang-questions