Previous: , Up: Pragmas   [Contents]


20.7 Old pragma syntax

Many of the pragmas above specify the identity of a predicate or a function as the entity to which the pragma applies. Their documentation shows these pragmas to have this syntax:

:- pragma pragma_name(pred(Name/Arity)).
:- pragma pragma_name(func(Name/Arity)).

New code should use this syntax. However, old versions of the Mercury compiler supported only a simpler version of this syntax, like this:

:- pragma pragma_name(Name/Arity).

Since this syntax does not specify whether the pragma is supposed to apply to a predicate or to a function, it is ambiguous in the event that the program contains both a predicate and a function with the given name and arity.

For backwards compatibility, the Mercury compiler still supports this syntax, but it will now generate a warning when the program contains both a predicate and a function with the given name and arity. It can also be asked to generate a warning for all pragmas that should specify whether they apply to a predicate or to a function but do not do so.

A later version of Mercury will deprecate this syntax, and a still later version will stop supporting it.