Basic builtin directives

Author(s): Daniel Cabeza.

This chapter documents the basic builtin directives in Ciao, additional to the documented in other chapters. These directives are natively interpreted by the Ciao compiler (ciaoc).

Unlike in other Prolog systems, directives in Ciao are not goals to be executed by the compiler or top level. Instead, they are read and acted upon by these programs. The advantage of this is that the effect of the directives is consistent for executables, code loaded in the top level, code analyzed by the preprocessor, etc.

As a result, by default only the builtin directives or declarations defined in this manual can be used in user programs. However, it is possible to define new declarations using the new_declaration/1 and new_declaration/2 directives (or using packages including them). Also, packages may define new directives via code translations.

Usage and interface

  • Library usage:
    These directives are builtin in Ciao, so nothing special has to be done to use them.
  • Imports:

Documentation on internals

DECLARATION

Usage:ISO:- multifile Predicates.

Specifies that each predicate in Predicates may have clauses in more than one file. Each file that contains clauses for a multifile predicate must contain a directive multifile for the predicate. The directive should precede all clauses of the affected predicates, and also dynamic/data declarations for the predicate. This directive is defined as a prefix operator in the compiler.

  • The following properties should hold at call time:
    (basic_props:sequence_or_list/2)Predicates is a sequence or list of prednames.

DECLARATION

Usage:ISO:- discontiguous Predicates.

Specifies that each predicate in Predicates may be defined in this file by clauses which are not in consecutive order. Otherwise, a warning is signaled by the compiler when clauses of a predicate are not consecutive (this behavior is controllable by the prolog flag discontiguous_warnings). The directive should precede all clauses of the affected predicates. This directive is defined as a prefix operator in the compiler.

  • The following properties should hold at call time:
    (basic_props:sequence_or_list/2)Predicates is a sequence or list of prednames.

DECLARATION

Usage::- impl_defined(Predicates).

Specifies that each predicate in Predicates is implicitly defined in the current prolog source, either because it is a builtin predicate or because it is defined in a C file. Otherwise, a warning is signaled by the compiler when an exported predicate is not defined in the module or imported from other module.

  • The following properties should hold at call time:
    (basic_props:sequence_or_list/2)Predicates is a sequence or list of prednames.

DECLARATION

Usage::- redefining(Predicate).

Specifies that this module redefines predicate Predicate, also imported from other module, or imports it from more than one module. This prevents the compiler giving warnings about redefinitions of that predicate. Predicate can be partially (or totally) uninstantiated, to allow disabling those warnings for several (or all) predicates at once.

  • The following properties should hold at call time:
    (basic_props:compat/2)Predicate is compatible with predname

DECLARATION

Usage:ISO:- initialization(Goal).

Goal will be executed at the start of the execution of any program containing the current code. The initialization of a module/file never runs before the initializations of the modules from which the module/file imports (excluding circular dependences).

  • The following properties should hold at call time:
    (basic_props:callable/1)Goal is a term which represents a goal, i.e., an atom or a structure.

DECLARATION

Usage::- on_abort(Goal).

Goal will be executed after an abort of the execution of any program containing the current code.

  • The following properties should hold at call time:
    (basic_props:callable/1)Goal is a term which represents a goal, i.e., an atom or a structure.