[erlang-questions] style question - best way to test multiple non-guard conditions sequentially
Anthony Ramine
n.oxyde@REDACTED
Mon Jul 8 10:35:25 CEST 2013
No this example was just confusing, what I meant is that if you need a warning "no clause will ever match" in the case of an explicit "case foobar of true -> ok; false -> ok end" and a warning "this clause will crash" in the case of "cond foobar -> ok; true -> ok end". There is no rewording that makes the warning fit in both situations, they need to be handled separately.
In my implementation I decided to annotate the Core Erlang cases to which a cond is compiled with the atom "cond_case".
--
Anthony Ramine
Le 8 juil. 2013 à 08:22, "Richard A. O'Keefe" <ok@REDACTED> a écrit :
>
> On 8/07/2013, at 6:04 PM, Anthony Ramine wrote:
>
>> With that logic, I see no reason to make if G -> B end different from case {} of {} when G -> B end.
>
> Neither do I. It is excess complexity that we really don't need,
> and it inhibits a range of source-to-source transformations that
> ought not to be inhibited.
>
> If I am told which *function clause* a selection failure is in,
> better still, if I am told which *line* it is in, no distinction
> between if/case/cond in exceptions is of any real help. The
> *only* time it is helpful is when you have one 'if' and one 'case'.
> Have *two* 'if's or *two* 'case's, and it's useless.
>
>>
>> Expanding cond to nested cases earlier in the compilation would mean confusing and misguided warning, e.g. "cond foobar -> ok end" would trigger the warning "no clause will ever match"; instead of the clearer "this clause will crash".
>
> You have presented a good argument for rewording the error message.
>
> That's all.
>
More information about the erlang-questions
mailing list