Next: , Previous: Introduction, Up: Top   [Contents]

2 Syntax and declarations

Prolog and Mercury have very similar syntax. Although there are a few differences, by and large if the syntax of a program is accepted by a Prolog system, it will be accepted by Mercury. There are however a few extra operators defined by the Mercury term parser (see the “Builtin operators” section of the “Syntax” chapter of the Mercury Language Reference Manual).

In addition, Mercury implements both existential and universal quantification using the syntax

some Vars Goal


all Vars Goal

The constructor for lists in Mercury is ‘[|]/2’, not ‘./2’.

Terms with functor ’{}/N’ are treated slightly differently in Mercury than in ISO Prolog. ISO Prolog specifies that “{1, 2, 3}” is parsed as '{}'(','(1, ','(2, 3))). In Mercury, it is parsed as '{}'(1, 2, 3).

Mercury does not allow users to define their own operators.