The following directives may occur in Prolog source files being read by
consult/1
or reconsult/1
or by the compiler; some may also
be entered interactively.
char_conversion
:- char_conversion(InChar, OutChar)
char_conversion/2
but only applies to the file in which it occurs and any files included by it.consult/1
or reconsult/1,
or by the compiler.:- char_conversion(a, b)
- causes every occurrence of a
in unquoted input in the current file to be replaced by b.
op
:- op(Priority, Associativity, Symbol)
op/3
but only applies to the file in which it occurs and any files included by it.consult/1
or reconsult/1,
or by the compiler.:- op(1000, xfy, foo)
- makes foo
an infix operator with priority 1000 and left associativity for the remainder of the current file.set_prolog_flag
:- set_prolog_flag(Name, Value)
set_prolog_flag/2
but only applies to the file in which it occurs and any files included by it.consult/1
or reconsult/1,
or by the compiler.:- set_prolog_flag(enforce_directives, off)
- set the enforce_directives
flag to off
for the remainder of the current file.discontiguous
:- discontiguous(PredicateIndicatorListOrSequence)
enforce_directives
flag is off.
:- discontiguous(test/1)
- declares test/1
discontiguous.:- discontiguous([ test/1, test/2 ])
- declares test/1
and test/2
to be discontiguous.:- discontiguous(test/1, test/2)
- declares test/1
and test/2
to be discontiguous.dynamic
:- dynamic(PredicateIndicatorListOrSequence)
asserta/1
or assertz/1
or removed by deny/1,
retract/1,
or retractall/1.
However, this requirement is not enforced if the enforce_directives
flag is off.
:- dynamic(test/1)
- declares test/1
dynamic.:- dynamic([ test/1, test/2 ])
- declares test/1
and test/2
to be dynamic.:- dynamic(test/1, test/2)
- declares test/1
and test/2
to be dynamic.local
:- local(PredicateIndicatorListOrSequence)
:- local(test/1)
- declares test/1
local.:- local([ test/1, test/2 ])
- declares test/1
and test/2
to be local.:- local(test/1, test/2)
- declares test/1
and test/2
to be local.multifile
:- multifile(PredicateIndicatorListOrSequence)
enforce_directives
flag is off.
:- multifile(test/1)
- declares test/1
multifile.:- multifile([ test/1, test/2 ])
- declares test/1
and test/2
to be multifile.:- multifile(test/1, test/2)
- declares test/1
and test/2
to be multifle.public
:- public(PredicateIndicatorListOrSequence)
clause/2.
(If a predicate is declared to be dynamic,
it is automatically made public
as well.)However, this requirement is not enforced if the enforce_directives
flag is off.
:- public(test/1)
- declares test/1
public.:- public([ test/1, test/2 ])
- declares test/1
and test/2
to be public.:- public(test/1, test/2)
- declares test/1
and test/2
to be public.ensure_loaded
:- ensure_loaded(Module)
Module
is loaded. The compiled form of a module is always loaded when this directive appears in source code being compiled. In other contexts, whether a compiled or source file is loaded depends on the setting of the ensure_loaded
flag.entry
:- entry(Signature, PrologName)
consult/1
or reconsult/1
:- entry(test(int), test)
- declares a Java entry whose signature is test(int)
that calls the Prolog predicate test/1.
function
:- function(Indicator, ClassName)
Indicator
specifies the Prolog name for the function, and whether it is binary, unary, or zeroary. The specified class implements the function - it must implement one of the interfaces PrologBinaryFunction,
PrologUnaryFunction,
or PrologZeroaryFunction,
as appropriate.:- function(f/1, MyFunction)
- declares a unary function named f that is implemented by the Java class MyFunction,
which must implement PrologUnaryFunction.
include
:- include(Path)
Path
to be included into the file being read at the point where the directive occurs.consult/1
or reconsult/1,
or by the compiler.:- include('foo/bar')
- causes foo/bar.pro
to be included into the source file.initialization
:- initialization(Goal)
consult/1
or reconsult/1,
or by the compiler.:- initialization(test(3))
- the goal test(3)
will be called when the file in which this directive occurs is consulted, or when code generated by compiling it is loaded.java
:- java(Indicator, Type, ClassName, Signature, ValueSpecifier)
:- java(example/1, method, MyClass, someMethod(int), _)
- declares example/1
as a Java predicate invoking the class method someMethod
of class MyClass,
with a single integer parameters.main
:- main(Functor)
consult/1
or reconsult/1
:- main(main)
- when this program is run, the goal main/1
(with arguments the command line arguments) will be the starting point for execution.message
:- message(Message, CompilerOnly)
Message
to current output when this directive is read while reading the file in which it occurs.consult/1
or reconsult/1,
or by the compiler. If CompilerOnly
is true,
the message is only printed when reading this file during compilation.sql
:- sql(Indicator, Type, URL, TableNameOrQuery)
:- sql(example/3, table, 'jdbc:mysql://localhost/mydatabase', sometable)
- declares example/3
as a relational database predicate accessing the table sometable
in the mysql database mydatabase
on the local computer.