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

Anthony Ramine n.oxyde@REDACTED
Tue Jul 16 03:20:19 CEST 2013


And reading your mail again, are you sure you meant that Bf should be executed? Whether in if or cond, that definitely sounds wrong.

-- 
Anthony Ramine

Le 16 juil. 2013 à 03:16, Anthony Ramine a écrit :

> I disagree.
> 
> In the case of 'if', the tests are disjunctions of conjunctions of guards; whereas in the case of 'cond' they should be boolean tests. So what is a valid 'if' clause may not be a 'cond' one.
> 
> Furthermore, in the case of 'if', the fact that foobar just fails silently is because guard semantics are used: the very thing that is not used in 'cond' expressions.
> 
> -- 
> Anthony Ramine
> 
> Le 16 juil. 2013 à 00:30, Richard A. O'Keefe a écrit :
> 
>> 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.
>> 
>> Consider
>> 	if E -> Bt ; true -> Bf end
>> and
>> 	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