[m-users.] Idiomatic Mercury - if-then-else or (C->I;E)

Mark Brown mark at mercurylang.org
Fri Nov 20 19:14:22 AEDT 2015


Hi Matthias,

On Fri, Nov 20, 2015 at 6:02 PM, Matthias Güdemann
<matthias.guedemann at googlemail.com> wrote:
> Hi,
>
> I just saw Julien's comment on Paul's example. There, and in other
> commits I saw a preference of if-then-else over (C->I;E) to write
> idiomatic Mercury.
>
> What are the reasons for this?

Personally I find that if the condition extends over multiple lines,
the (C->T;E) form is harder to follow because you can't tell it's a
condition until you reach the end. That's particularly the case with
long if-then-else chains: each goal occurring after one of the
semicolons could either be a condition or the else clause, and the key
to telling which may be many lines away.

Other reasons include that it looks like implication, which it's not,
and that Mercury syntax already uses too many different kinds of
arrows.

Mark



More information about the users mailing list