PrologJ Directives

Overview

PrologJ recognizes 13 directives of the form :-/1. Any can appear in a source file that is being read by the compiler. Most can appear in a file that is being consulted by using the Prolog built-in predicates consult/1 or reconsult/1 or by the using the API methods consult() or reconsult(). Many can also appear in input to the interpreter. Insofar as possible, these directives produce equivalent results, regardless of how they are read. The following table shows the contexts in which the various directives may appear.

DirectivePermitted Contexts
:- char_conversionCompiler source or consulted source only. (Notes 1, 2)
:- commentCompiler source or consulted source only. (Note 5)
:- discontiguousAny
:- dynamicAny
:- ensure_loadedAny
:- entryCompiler source only (Note 4)
:- includeCompiler source or consulted source only. (Note 3)
:- initializationCompiler source or consulted source only. (Note 3)
:- mainCompiler source only (Note 4)
:- multifileAny
:- opCompiler source or consulted source only. (Notes 1, 2)
:- packageCompiler source only (Note 4)
:- dynamicAny
:- set_prolog_flagCompiler source or consulted source only. (Notes 1, 2)

Notes:

  1. This directive only affects the file it is contained in, as well as any file that file includes, or any file that includes it. Its effect on the database is removed when the compile or (re)consult operation that resulted (directly or indirectly) in reading the file is completed. If it is desired to permanently alter a character conversion, flag, or operator definition, the appropriate char_conversion/2, op/3 or set_prolog_flag/2 built-in should be called in an :- initialization/1 directive as well. (Both are needed; the directive to affect the reading of the file, and the built-in predicate call to affect the execution of the program contained in the file.)
     
  2. It is an error to use this directive in interactive input or a file of goals that is being interpreted by the interpreter. The built-in predicates char_conversion/2, op/3 or set_prolog_flag/2 can be used as interpreted goals with the same effect.
     
  3. This directive is only meaningful in source code that is being compiled or consulted. It is an error to use this directive in input to the interpreter.
     
  4. This directive is only meaningful in source code that is being compiled. It results in a warning message and is ignored if it appears in a source file being consulted. This facilitates developing source code interpretively before compiling it. It is an error to use this directive in input to the interpreter.
     
  5. This directive is only meaningful in source code that is being compiled. It is ignored if it appears in a source file being consulted. This facilitates developing source code interpretively before compiling it. It is an error to use this directive in input to the interpreter.
     

Meaning of the Various Directives

Notes:

  1. The ISO standard specifies that only predicates explictly declared discontiguous can have clauses that appear at more than one location in a source file, and only predicates that are explicitly declared multifile can have clauses that appear in more than one source file.
     
    If the enforce_directives flag is off, information about the properties of predicates is still maintained, but these requirements are not enforced.
     
  2. The ISO standard specifies that only dynamic predicates can be altered by asserta/1, assertz/1, retract/1 or retractall/1. Only public predicates can be accessed by clause/2. (A predicate that is made dynamic is also automatically made public.) Predicates created by asserta/1 or assertz/1 are made dynamic and public, but predicates created by clauses in a source file are static and private unless explicitly declared otherwise.
     
    If the enforce_directives flag is off, information about the properties of predicates is still maintained, but these requirements are not enforced.
     
Copyright © 2005 - Russell C. Bjork. See the file See file COPYING in the root directory for copyright information.

Valid XHTML 1.0!