The other thing is that I don't understand what the proposal is.<br><br>One post above states the the following would be identical.<br><br><span class="nfakPe">cond</span><br>
Test1 -><br>
Result1;<br>
Test2 -><br>
Result2;<br>
Test... -><br>
Result...;<br>
true -><br>
yay<br>
end<br>
<br>
<br>
case Test1 of<br>
true -> Result1;<br>
false -><br>
case Test2 of<br>
true -> Result2;<br>
false -><br>
case Test... of<br>
true -> Result...<br>
false -> yay<br>
end<br>
end<br>
end<br><br>In the latter, each of the TestN conditions is a boolean expression; that is, it returns either the atom 'true' or the atom 'false', otherwise a bad match exception is thrown. In the proposed "cond" construct above, are the TestN expressions the same; the 'true' atom in the last conditions would suggest that this is the case.<br>
<br>However, I saw an example in another post as follows:<br><br><span class="nfakPe">cond</span><br>
{ok, X} = f(Y) -> g(X); %% clause 1<br>
true -> h(X) %% clause 2<br>
end<br><br>The expression {ok, X} = f(Y) does not evaluate to 'true' or 'false'; it evaluate to {ok, X}. And given the generalization above would be equivalent to be:<br><br>case {ok, X} = f(Y) of <br> true-> g(x);<br>
false-> h(x)<br>end<br><br>... which would always result in a bad match exception. I'm assuming this example is erroneous. Perhaps what was meant was <br><br><span class="nfakPe">cond</span><br>
{ok, X} =:= f(Y) -> g(X); %% clause 1<br>
true -> h(X) %% clause 2<br>
end <br><br>... in which case X whould have to be bound prior to this expression being evaluated, otherwise an exception would be thrown.<br><br>So perhaps someone could better explain the usage of this proposed 'cond' construct and give some examples.<br>
<br>