[erlang-questions] style question - best way to test multiple non-guard conditions sequentially

Richard A. O'Keefe ok@REDACTED
Tue Jul 16 00:30:04 CEST 2013

When there is a choice between two constructs such as
	if G -> Bt ; true -> Bf end
and	case {} of {} when G -> Bt ; {} when true -> Bf end
that *LOOKS* as though it is purely stylistic,
it should *BE* purely stylistic.

	if E -> Bt ; true -> Bf end
	cond E -> Bt ; true -> Bf end

where E is such that both forms are syntactically legal.
It *looks* as though the choice is purely stylistic.
So it should *be* purely stylistic, otherwise it would
be gratuitously difficult to change from one to the other.
And that means that

	cond foobar -> Bt ; true -> Bf end

should execute Bf and NOT complain about foobar.
(Yes, my prototype got this wrong.  I just hadn't thought
it through clearly.)

More information about the erlang-questions mailing list