Next: , Up: Data-terms   [Contents]


2.15.1 Data-functors

A data-functor is an integer, a float, a string, a name, an implementation-defined literal, or a compound data-term.

Character literals are written as single-character names, quoted or unquoted. If the character is an operator, it will be necessary to enclose the name within parentheses in some contexts, e.g. (':').

A compound data-term is a compound term which does not match the form of a special data-term (see Data-terms), and whose arguments are data-terms. If a data-functor is a name or a compound data-term, its top-level functor must name a function, predicate, or data constructor declared in the module or in the interface of an imported module.

Implementation-defined literals are symbolic names whose value represents a property of the compilation environment or the context in which it appears. The implementation replaces these symbolic names with actual constants during compilation. Implementation-defined literals can only appear within clauses. The following literals must be supported by all Mercury implementations:

$file

a string that gives the name of the file that contains the module being compiled. If the name of the file cannot be determined, then it is replaced by an arbitrary string.

$line

the line number (integer) of the goal in which the literal appears, or -1 if it cannot be determined.

$module

a string representation of the fully qualified module name.

$pred

a string containing the fully qualified predicate or function name and arity.

The Melbourne Mercury implementation additionally supports the following extension:

$grade

the grade (string) in which the module is compiled.


Next: , Up: Data-terms   [Contents]