[mercury-users] Mercury needs a Tutorial

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Feb 15 15:51:33 AEDT 1999


On 15-Feb-1999, David Powers <powers at ist.flinders.edu.au> wrote:
> 
> In teaching Prolog I strongly discourage use of ; (probably pretty
> common), and also -> ; (less common).  Possibly it is only the nesting
> of these I should discourage, particularly as there are optimizations
> which are lost by doing so.  It may be worth commenting on this (to
> Prolog programmers) if there are special reasons why these are used in
> Mercury where they would not be in Prolog.

For Mercury, I would suggest using the `if ... then ... else' syntax
rather than the `... -> ... ; ...' syntax, which is really only there
for Prolog compatibility.  I don't think there is any good reason for
a tutorial to discourage the use of disjunction or if-then-else in
Mercury.  But a tutorial should teach the use of appropriate layout
conventions.

Even in Prolog, I think it would be a bad idea to discourage the use
of if-then-else.  In Prolog, the usual alternative to if-then-else is
to use cuts, and if-then-else is easier to understand and easier to
get right than cuts.  And Mercury of course doesn't have cut, so in
Mercury there's basically no alternative to using if-then-else.

In Prolog you may wish to avoid using disjunction for optimization
reasons (clause indexing), but those considerations don't apply in Mercury.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "Binaries may die
WWW: <http://www.cs.mu.oz.au/~fjh>  |   but source code lives forever"
PGP: finger fjh at 128.250.37.3        |     -- leaked Microsoft memo.



More information about the users mailing list