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

Richard A. O'Keefe ok@REDACTED
Mon Jul 8 08:22:02 CEST 2013

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