[m-users.] Mercury operators explained
jfischer at opturion.com
Wed Feb 19 10:23:57 AEDT 2014
On Wed, Feb 19, 2014 at 9:30 AM, Zoltan Somogyi
<zoltan.somogyi at runbox.com>wrote:
> There is no =\= operator in Mercury, because there is no need for one.
> In Prolog, the unification operator = operates on unevaluated terms. If
> you give it two
> arithmetic expressions, it will tell you whether they have the same
> structure, but not
> whether they evaluate to the same result. Arithmetic expressions are
> evaluated only
> in special contexts, such as the operands of =\= or the right hand side of
> the "is" operator.
> In Mercury, function calls (such as calls to the arithmetic functions) are
> evaluated wherever
> they happen to be. So in Mercury, you use the usual equality operator =
> where in Prolog
> you would use =\=.
> Note that Mercury is NOT a Prolog dialect. Semantically, it is
> significantly different from
> Prolog in several respects; this is one. Attempts to transliterate
> nontrivial Prolog programs
> into Mercury won't work if the person doing the transliterating doesn't
> know the differences.
> As for the list of operators in the Mercury language reference manual,
> some are built-in
> constructs of the language, and are explained in the relevant section of
> that manual,
> and some represent functions in the Mercury standard library, and are
> in the library's reference manual.
It's worth pointing out here that the standard library does include a
that is intended to assist with porting Prolog programs to Mercury. It
does define the
=\= operator appropriately for Mercury (i.e. it's just a synonym for '=').
for further details.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the users