Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > d1f06a5336fd6bf4a381b72b8d2b5ce1 > files > 156

gprolog-1.2.16-3mdk.ppc.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>

<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.06-7 of 2001-11-14">
<TITLE>
 Prolog directives
</TITLE>
</HEAD>
<BODY TEXT=black BGCOLOR=white>
<A HREF="manual020.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<A HREF="manual022.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>
<TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#66dbff"><DIV ALIGN=center><TABLE>
<TR><TD><FONT SIZE=4><B><A NAME="htoc45">6.1</A></B></FONT></TD>
<TD WIDTH="100%" ALIGN=center><FONT SIZE=4><B>Prolog directives</B></FONT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE><UL>
<LI><A HREF="manual021.html#toc26"> Introduction</A>
<LI><A HREF="manual021.html#toc27"> <TT>dynamic/1</TT></A>
<LI><A HREF="manual021.html#toc28"> <TT>public/1</TT></A>
<LI><A HREF="manual021.html#toc29"> <TT>multifile/1</TT></A>
<LI><A HREF="manual021.html#toc30"> <TT>discontiguous/1</TT></A>
<LI><A HREF="manual021.html#toc31"> <TT>ensure_linked/1</TT></A>
<LI><A HREF="manual021.html#toc32"> <TT>built_in/0</TT>,
 <TT>built_in/1</TT>,
 <TT>built_in_fd/0</TT>,
 <TT>built_in_fd/1</TT></A>
<LI><A HREF="manual021.html#toc33"> <TT>include/1</TT></A>
<LI><A HREF="manual021.html#toc34"> <TT>ensure_loaded/1</TT></A>
<LI><A HREF="manual021.html#toc35"> <TT>op/3</TT></A>
<LI><A HREF="manual021.html#toc36"> <TT>char_conversion/2</TT></A>
<LI><A HREF="manual021.html#toc37"> <TT>set_prolog_flag/2</TT></A>
<LI><A HREF="manual021.html#toc38"> <TT>initialization/1</TT></A>
<LI><A HREF="manual021.html#toc39"> <TT>foreign/2</TT>,
 <TT>foreign/1</TT></A>
</UL>
<BR>
<A NAME="toc26"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc46">6.1.1</A></B></TD>
<TD WIDTH="100%" ALIGN=center><B>Introduction</B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
Prolog directives are annotations inserted in Prolog source files for the
compiler. A Prolog directive is used to specify:
<UL><LI>the properties of some procedures defined in the source file.<BR>
<BR>
<LI>the format and the syntax for read-terms in the source file (using
changeable Prolog flags).<BR>
<BR>
<LI>included source files.<BR>
<BR>
<LI>a goal to be executed at run-time.</UL>
<A NAME="toc27"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc47">6.1.2</A></B></TD>
<TD WIDTH="100%" ALIGN=center><TT><B>dynamic/1</B></TT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
<A NAME="dynamic/1"></A>
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
dynamic(+predicate_indicator)<BR>
dynamic(+predicate_indicator_list)<BR>
dynamic(+predicate_indicator_sequence)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>dynamic(Pred)</TT> specifies that the procedure whose
predicate indicator is <TT>Pred</TT> is a dynamic procedure. This directive
makes it possible to alter the definition of <TT>Pred</TT> by adding or
removing clauses. For more information refer to the section about dynamic
clause management (section&nbsp;<A HREF="manual030.html#Introduction:(Dynamic-clause-management)">7.7.1</A>).<BR>
<BR>
This directive shall precede the definition of <TT>Pred</TT> in the source
file.<BR>
<BR>
If there is no clause for <TT>Pred</TT> in the source file, <TT>Pred</TT>
exists however as an empty predicate (this means that
<TT>current_predicate(Pred)</TT> succeeds). <BR>
<BR>
In order to allow multiple definitions, <TT>Pred</TT> can also be a list of
predicate indicators or a sequence of predicate indicators using
<TT>','/2</TT> as separator.<BR>
<BR>
<B>Portability</B><BR>
<BR>
ISO directive.<BR>
<BR>
<A NAME="toc28"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc48">6.1.3</A></B></TD>
<TD WIDTH="100%" ALIGN=center><TT><B>public/1</B></TT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
<A NAME="public/1"></A>
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
public(+predicate_indicator)<BR>
public(+predicate_indicator_list)<BR>
public(+predicate_indicator_sequence)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>public(Pred)</TT> specifies that the procedure whose predicate indicator
is <TT>Pred</TT> is a public procedure. This directive makes it possible to
inspect the clauses of <TT>Pred</TT>. For more information refer to the
section about dynamic clause management (section&nbsp;<A HREF="manual030.html#Introduction:(Dynamic-clause-management)">7.7.1</A>).<BR>
<BR>
This directive shall precede the definition of <TT>Pred</TT> in the source
file. Since a dynamic procedure is also public. It is useless (but correct)
to define a public directive for a predicate already declared as dynamic.<BR>
<BR>
In order to allow multiple definitions, <TT>Pred</TT> can also be a list of
predicate indicators or a sequence of predicate indicators using
<TT>','/2</TT> as separator.<BR>
<BR>
<B>Portability</B><BR>
<BR>
GNU Prolog directive. The ISO reference does not define any directive to
declare a predicate public but it does distinguish public predicates. It is
worth noting that in most Prolog systems the <TT>public/1</TT> directive is
as a visibility declaration. Indeed, declaring a predicate as public makes
it visible from any predicate defined in any other file (otherwise the
predicate is only visible from predicates defined in the same source file as
itself). When a module system is incorporated in GNU Prolog a more general
visibility declaration shall be provided conforming to the ISO reference.<BR>
<BR>
<A NAME="toc29"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc49">6.1.4</A></B></TD>
<TD WIDTH="100%" ALIGN=center><TT><B>multifile/1</B></TT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
multifile(+predicate_indicator)<BR>
multifile(+predicate_indicator_list)<BR>
multifile(+predicate_indicator_sequence)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>multifile(Pred)</TT> is not supported by GNU Prolog.
When such a directive is encountered it is simply ignored. All clauses for a
given predicate must reside in a single file.<BR>
<BR>
<B>Portability</B><BR>
<BR>
ISO directive. Not supported.<BR>
<BR>
<A NAME="toc30"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc50">6.1.5</A></B></TD>
<TD WIDTH="100%" ALIGN=center><TT><B>discontiguous/1</B></TT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
discontiguous(+predicate_indicator)<BR>
discontiguous(+predicate_indicator_list)<BR>
discontiguous(+predicate_indicator_sequence)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>discontiguous(Pred)</TT> specifies that the procedure whose predicate
indicator is <TT>Pred</TT> is a discontiguous procedure. Namely, the clauses
defining <TT>Pred</TT> are not restricted to be consecutive but can appear
anywhere in the source file.<BR>
<BR>
This directive shall precede the definition of <TT>Pred</TT> in the source
file.<BR>
<BR>
In order to allow multiple definitions, <TT>Pred</TT> can also be a list of
predicate indicators or a sequence of predicate indicators using
<TT>','/2</TT> as separator.<BR>
<BR>
<B>Portability</B><BR>
<BR>
ISO directive. The ISO reference document states that if there is no clause
for <TT>Pred</TT> in the source file, <TT>Pred</TT> exists however as an
empty predicate (i.e. <TT>current_predicate(Pred)</TT> will succeed). This
is not the case for GNU Prolog.<BR>
<BR>
<A NAME="toc31"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc51">6.1.6</A></B></TD>
<TD WIDTH="100%" ALIGN=center><TT><B>ensure_linked/1</B></TT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
ensure_linked(+predicate_indicator)<BR>
ensure_linked(+predicate_indicator_list)<BR>
ensure_linked(+predicate_indicator_sequence)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>ensure_linked(Pred)</TT> specifies that the procedure
whose predicate indicator is <TT>Pred</TT> must be included by the linker.
This directive is useful when compiling to native code to force the linker to
include the code of a given predicate. Indeed, if the <TT>gplc</TT> is
invoked with an option to reduce the size of the executable
(section&nbsp;<A HREF="manual008.html#Using-the-compiler">3.4.3</A>), the linker only includes the code of predicates
that are statically referenced. However, the linker cannot detect dynamically
referenced predicates (used as data passed to a meta-call predicate). The use
of this directive prevents it to exclude the code of such predicates.<BR>
<BR>
In order to allow multiple definitions, <TT>Pred</TT> can also be a list of
predicate indicators or a sequence of predicate indicators using
<TT>','/2</TT> as separator.<BR>
<BR>
<B>Portability</B><BR>
<BR>
GNU Prolog directive.<BR>
<BR>
<A NAME="toc32"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc52">6.1.7</A></B></TD>
<TD WIDTH="100%" ALIGN=center><B><TT>built_in/0</TT>,
 <TT>built_in/1</TT>,
 <TT>built_in_fd/0</TT>,
 <TT>built_in_fd/1</TT></B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
 
 
 
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
built_in<BR>
built_in(+predicate_indicator)<BR>
built_in(+predicate_indicator_list)<BR>
built_in(+predicate_indicator_sequence)<BR>
built_in_fd<BR>
built_in_fd(+predicate_indicator)<BR>
built_in_fd(+predicate_indicator_list)<BR>
built_in_fd(+predicate_indicator_sequence)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>built_in</TT> specifies that the procedures defined from
now have the <TT>built_in</TT> property (section&nbsp;<A HREF="manual031.html#predicate-property/2">7.8.2</A>).<BR>
<BR>
<TT>built_in(Pred)</TT> is similar to <TT>built_in/0</TT> but
only affects the procedure whose predicate indicator is <TT>Pred</TT>.<BR>
<BR>
This directive shall precede the definition of <TT>Pred</TT> in the source
file.<BR>
<BR>
In order to allow multiple definitions, <TT>Pred</TT> can also be a list of
predicate indicators or a sequence of predicate indicators using
<TT>','/2</TT> as separator.<BR>
<BR>
<TT>built_in_fd</TT> (resp.
<TT>built_in_fd(Pred)</TT>) is similar to
<TT>built_in</TT> (resp. <TT>built_in(Pred)</TT>) but sets the
<TT>built_in_fd</TT> predicate property (section&nbsp;<A HREF="manual031.html#predicate-property/2">7.8.2</A>).<BR>
<BR>
<B>Portability</B><BR>
<BR>
GNU Prolog directives.<BR>
<BR>
<A NAME="toc33"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc53">6.1.8</A></B></TD>
<TD WIDTH="100%" ALIGN=center><TT><B>include/1</B></TT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
include(+atom)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>include(File)</TT> specifies that the content of the Prolog source
<TT>File</TT> shall be inserted. The resulting Prolog text is identical to
the Prolog text obtained by replacing the directive by the content of the
Prolog source <TT>File</TT>.<BR>
<BR>
See <TT>absolute_file_name/2</TT> for information about the syntax of
<TT>File</TT> (section&nbsp;<A HREF="manual049.html#absolute-file-name/2">7.26.1</A>).<BR>
<BR>
<B>Portability</B><BR>
<BR>
ISO directive.<BR>
<BR>
<A NAME="toc34"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc54">6.1.9</A></B></TD>
<TD WIDTH="100%" ALIGN=center><TT><B>ensure_loaded/1</B></TT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
ensure_loaded(+atom)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>ensure_loaded(File)</TT> is not supported by GNU Prolog. When such a
directive is encountered it is simply ignored.<BR>
<BR>
<B>Portability</B><BR>
<BR>
ISO directive. Not supported.<BR>
<BR>
<A NAME="toc35"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc55">6.1.10</A></B></TD>
<TD WIDTH="100%" ALIGN=center><TT><B>op/3</B></TT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
<A NAME="op/3"></A>
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
op(+integer, +operator_specifier, +atom_or_atom_list)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>op(Priority, OpSpecifier, Operator)</TT> alters the operator table. This
directive is executed as soon as it is encountered by calling the built-in
predicate <TT>op/3</TT> (section&nbsp;<A HREF="manual037.html#op/3:(Term-input/output)">7.14.10</A>). A system
directive is also generated to reflect the effect of this directive at
run-time (section&nbsp;<A HREF="manual008.html#Running-an-executable">3.4.4</A>).<BR>
<BR>
<B>Portability</B><BR>
<BR>
ISO directive.<BR>
<BR>
<A NAME="toc36"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc56">6.1.11</A></B></TD>
<TD WIDTH="100%" ALIGN=center><TT><B>char_conversion/2</B></TT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
char_conversion(+character, +character)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>char_conversion(InChar, OutChar)</TT> alters the character-conversion
mapping. This directive is executed as soon as it is encountered by a call
to the built-in predicate <TT>char_conversion/2</TT>
(section&nbsp;<A HREF="manual037.html#char-conversion/2">7.14.12</A>). A system directive is also generated to reflect
the effect of this directive at run-time (section&nbsp;<A HREF="manual008.html#Running-an-executable">3.4.4</A>).<BR>
<BR>
<B>Portability</B><BR>
<BR>
ISO directive.<BR>
<BR>
<A NAME="toc37"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc57">6.1.12</A></B></TD>
<TD WIDTH="100%" ALIGN=center><TT><B>set_prolog_flag/2</B></TT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
set_prolog_flag(+flag, +term)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>set_prolog_flag(Flag, Value)</TT> sets the value of the
Prolog flag <TT>Flag</TT> to <TT>Value</TT>. This directive is
executed as soon as it is encountered by a call to the built-in predicate
<TT>set_prolog_flag/2</TT> (section&nbsp;<A HREF="manual045.html#set-prolog-flag/2">7.22.1</A>). A system directive
is also generated to reflect the effect of this directive at run-time
(section&nbsp;<A HREF="manual008.html#Running-an-executable">3.4.4</A>).<BR>
<BR>
<B>Portability</B><BR>
<BR>
ISO directive.<BR>
<BR>
<A NAME="toc38"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc58">6.1.13</A></B></TD>
<TD WIDTH="100%" ALIGN=center><TT><B>initialization/1</B></TT></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
<A NAME="initialization/1"></A>
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
initialization(+callable_term)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>initialization(Goal)</TT> adds <TT>Goal</TT> to the set of goal which
shall be executed at run-time. A user directive is generated to execute
<TT>Goal</TT> at run-time. If several initialization directives appear in
the same file they are executed in the order of appearance
(section&nbsp;<A HREF="manual008.html#Running-an-executable">3.4.4</A>).<BR>
<BR>
<B>Portability</B><BR>
<BR>
ISO directive.<BR>
<BR>
<A NAME="toc39"></A><TABLE CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
<TR><TD BGCOLOR="#98e7ff"><DIV ALIGN=center><TABLE>
<TR><TD><B><A NAME="htoc59">6.1.14</A></B></TD>
<TD WIDTH="100%" ALIGN=center><B><TT>foreign/2</TT>,
 <TT>foreign/1</TT></B></TD>
</TR></TABLE></DIV></TD>
</TR></TABLE>
<A NAME="foreign/2"></A>
 
 <BR>
<B>Templates</B>
<DL COMPACT=compact><DT><DD><TT>
foreign(+callable_term, +foreign_option_list)<BR>
foreign(+callable_term)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>foreign(Template, Options)</TT> defines an interface predicate whose
prototype is <TT>Template</TT> according to the options given by
<TT>Options</TT>. Refer to the foreign code interface for more information
(section&nbsp;<A HREF="manual066.html#Calling-C-from-Prolog">9.1</A>).<BR>
<BR>
<TT>foreign(Template)</TT> is equivalent to <TT>foreign(Template, [])</TT>.<BR>
<BR>
<B>Portability</B><BR>
<BR>
GNU Prolog directive.<BR>
<BR>

<HR SIZE=2>
Copyright (C) 1999-2002 Daniel Diaz
<BR>
<BR>
Verbatim copying and distribution of this entire article is permitted in any
medium, provided this notice is preserved. <BR>
<BR>
<A HREF="index.html#copyright">More about the copyright</A>
<HR>
<A HREF="manual020.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<A HREF="manual022.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>