Guards and side effects
Fri Mar 11 11:24:20 CET 2005
Thomas Johnsson XA (LN/EAB) wrote:
> (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 ....
Getting information from a process has no side effect.
I think there is a conceptual problem with side effect in guards.
Functions clause are selected by guards, but what happens if the guard
do real side-effect processing and the clause if finally not selected ?
It will result in side effect generated bu clause that are different
from the executed clause. In my opinion, this seems at least at first
sight conter intuitive and can lead to program very hard to debug.
More information about the erlang-questions