UNPKG

@ciao-lang/ts-ciao-interface

Version:

Simple Ciao interface for node.

101 lines (99 loc) 37.4 kB
<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><meta name="theme-color" content="#273f79"/><link rel="stylesheet" href="lpdoc.css" type="text/css"/><script type="text/javascript" src="lpdoc.js"></script><title>The module system &mdash; The Ciao System v1.22</title></head><body><div class="lpdoc-page fixleftbar"><a href="#" id="sidebar-toggle-button" class="lpdoc-navbutton"><span id="sidebar-button-arrow">&#9776;</span></a><div id="sidebar" class="lpdoc-sidebar"><div style="height: 40px; margin-left: auto; margin-right: auto"><img src="ciao-logo_autofig.png" width=auto height=100%></div><div class="lpdoc-nav"><span class="lpdoc-on-right"><a class="lpdoc-navbutton" href="BasicLang.html">&#x2191;</a><a class="lpdoc-navbutton" href="Conventions.html">&#x2190;</a><a class="lpdoc-navbutton" href="bundles_doc.html">&#x2192;</a><a class="lpdoc-navbutton" href="ciaosearch.html">&#x1F50D;</a></span><span><a href="ciaofulltoc.html">TOC</a></span></div><hr></hr><ul class="lpdoc-itemize-sectpath"><li><a href="ciao.html">The Ciao System</a> &raquo;<br/> </li><li><a href="BasicLang.html">PART II - The Ciao basic language</a> &raquo;<br/> </li><li><a href=""><strong>The module system</strong></a></li></ul><hr></hr><em>ON THIS PAGE</em><ul><li><a href="#Visibility rules">Visibility rules</a></li><li><a href="#Files with no module declaration (&apos;user&apos; files)">Files with no module declaration (&apos;user&apos; files)</a></li><li><a href="#Multifile predicates">Multifile predicates</a></li><li><a href="#Basic directives">Basic directives</a></li><li><a href="#Libraries imported by default (&apos;builtins&apos;)">Libraries imported by default (&apos;builtins&apos;)</a></li><li><a href="#Usage and interface">Usage and interface</a></li><li><a href="#Documentation on exports">Documentation on exports</a></li><li><a href="#Documentation on internals">Documentation on internals</a></li><li><a href="#Documentation on imports">Documentation on imports</a></li></ul></div><div class="lpdoc-main"><div id=""><h1>The module system</h1><a class="lpdoc-idx-anchor" href="ciaosearch.html#modules"></a> <strong>Author(s):</strong> <a class="lpdoc-idx-anchor" id="Daniel Cabeza" href="ciaosearch.html#Daniel Cabeza">Daniel Cabeza</a>, <a class="lpdoc-idx-anchor" id="The Ciao Development Team" href="ciaosearch.html#The Ciao Development Team">The Ciao Development Team</a>.<p> Modularity is a basic notion in a modern computer language. Modules allow dividing programs into several parts, which have their own independent name spaces. Each module is written in its own file (see <a class="lpdoc-idx-anchor" id="0" href="#module/2"><tt>module/2</tt></a> and <a class="lpdoc-idx-anchor" id="1" href="#module/3"><tt>module/3</tt></a>) and consists of a sequence of <a class="lpdoc-idx-anchor" id="2" href="ciaosearch.html#directives">directives</a> and <a class="lpdoc-idx-anchor" id="3" href="ciaosearch.html#predicate">predicate</a> definitions.<p>Modules provide functionality to other modules by <em>exporting</em> some of the predicates defined inside the module (and also through <a class="lpdoc-idx-anchor" id="4" href="ciaosearch.html#multifile">multifile</a> predicates). However, a module does not modify the <em>syntax</em> that can be used in another module that loads it. This is done instead through the mechanism of <a class="lpdoc-idx-anchor" id="5" href="ciaosearch.html#package">package</a>s (see <a href="packages.html">Packages and language extension</a>).<p>See [<a class="lpdoc-idx-anchor" id="6" href="ciaorefs.html#ciao-modules-cl2000">CH00a</a>] for a detailed description of the Ciao module system.<p><div id="Visibility rules"><h4>Visibility rules</h4> <p>The module system in Ciao is, as in most Prolog implementations, <em>procedure based</em>. This means that predicate names are local to a module, but functor/atom names in data are shared (at least by default).<p>The <em>predicates visible in a module</em> are the predicates defined in that module, plus the predicates imported from other modules. Only predicates exported by a module can be imported from other modules. The default module of a given predicate name is the local one if the predicate is defined locally, else the <em>last</em> module from which the predicate is imported, where explicit imports have priority over implicit ones (that is, a predicate imported through a <tt>use_module/2</tt> declaration is always preferred over a predicate imported through a <tt>use_module/1</tt> declaration). To refer to a predicate from a module which is not the default module for that predicate the name has to be module <a class="lpdoc-idx-anchor" id="7" href="ciaosearch.html#module qualification"></a>qualified. A module-qualified predicate name has the form <span class="lpdoc-var">Module</span>:<span class="lpdoc-var">Predicate</span> as in the call <tt>debugger:debug_module(M)</tt>. Note that in Ciao this module qualification cannot be used for gaining access to predicates that have not been imported, nor for defining clauses of other modules.<p></div><div id="Files with no module declaration (&apos;user&apos; files)"><h4>Files with no module declaration (&apos;user&apos; files)</h4> <p>All predicates defined in files with no module declaration belong to a special module called <a class="lpdoc-idx-anchor" id="8" href="ciaosearch.html#user module"></a> <tt>user</tt>, from which they are all implicitly exported. This provides backward compatibility for programs written for Prolog implementations with no module system and allows dividing programs into several files without being aware of the module system at all. Note that this feature is only supported for the above-mentioned backward-compatibility reasons, and the use of <tt>user</tt> files is discouraged. Many attractive compilation features of Ciao cannot be supported for <tt>user</tt> modules.<p></div><div id="Multifile predicates"><h4>Multifile predicates</h4> <p>The case of multifile predicates (defined with the declaration <a class="lpdoc-idx-anchor" id="9" href="toplevel_doc.html#multifile/1"><tt>multifile/1</tt></a>) is also special. Multifile predicates can be defined by clauses distributed in several modules, and all modules which define a predicate as multifile can use that predicate. The name space of multifile predicates is independent, as if they belonged to the special module <tt>multifile</tt>.<p></div><div id="Basic directives"><h4>Basic directives</h4> <p>Unlike in other Prolog systems, directives in Ciao are not goals to be <em>executed</em> by the compiler or top level. Instead, they are <em>read</em> 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.<p>As a result, by default only the builtin directives or declarations defined in this section are available in user programs. However, it is possible to define new declarations <a class="lpdoc-idx-anchor" id="10" href="ciaosearch.html#declarations, user defined"></a> using the <a class="lpdoc-idx-anchor" id="11" href="packages.html#new_declaration/1"><tt>new_declaration/1</tt></a> and <a class="lpdoc-idx-anchor" id="12" href="packages.html#new_declaration/2"><tt>new_declaration/2</tt></a> directives (or using packages including them). Also, packages may define new directives via code translations.<p></div><div id="Libraries imported by default (&apos;builtins&apos;)"><h4>Libraries imported by default (&apos;builtins&apos;)</h4> <p>While in Ciao there are no &apos;built-in&apos; predicates (i.e., predicates whose load cannot be avoided or that that cannot be redefined --see below) for convenience every module or <tt>user file</tt> imports implicitly a number of modules called <a class="lpdoc-idx-anchor" id="13" href="ciaosearch.html#builtin modules">builtin modules</a> (also referred to as <a class="lpdoc-idx-anchor" id="14" href="ciaosearch.html#default modules">default modules</a>). Which exact modules are imported by default is controlled by the third argument of <a class="lpdoc-idx-anchor" id="15" href="#module/3"><tt>module/3</tt></a> declarations, the lack thereof in <a class="lpdoc-idx-anchor" id="16" href="#module/2"><tt>module/2</tt></a> declarations, some rules for user files, etc., as described below. For example, for backward compatibility with traditional Prolog systems, if a <a class="lpdoc-idx-anchor" id="17" href="#module/2"><tt>module/2</tt></a> declaration is used, then the traditional predicates that are built in in most Prolog systems are imported in that module (see <a href="classic_doc.html">Classic Prolog</a>).<p>Predicates coming from builtin/default modules are imported before all other importations of the module. This allows the <a class="lpdoc-idx-anchor" id="18" href="ciaosearch.html#redefinition of builtins">redefinition of builtins</a>, i.e., the redefinition of any of the predicates imported by default from builtin/default modules (with the exception of <a class="lpdoc-idx-anchor" id="19" href="basiccontrol.html#true/0"><tt>true/0</tt></a>) by either defining local versions of these predicates or by importing them from other modules.<p>Moreover, the implicit importation of the basic modules can be fully disabled by some special packages (for example, omitting all default imports with <a class="lpdoc-idx-anchor" id="20" href="noprelude_doc.html"><tt>noprelude</tt></a>, or defining <a class="lpdoc-idx-anchor" id="21" href="ciaosearch.html#pure Prolog">pure Prolog</a> modules with the <a class="lpdoc-idx-anchor" id="22" href="pure_doc.html"><tt>pure</tt></a> package).</div><br/><div id="Usage and interface"><h2>Usage and interface</h2><div class="lpdoc-cartouche"><ul><li><strong>Library usage:</strong><br/>Modules are an intrinsic feature of Ciao, so nothing special has to be done to use them.<li><strong>Exports:</strong><br/><ul class="lpdoc-itemize-minus"><li><em>Regular Types:</em><br/><a class="lpdoc-idx-anchor" id="23" href="#modulename/1"><tt>modulename/1</tt></a>. </ul></ul></div></div><div id="Documentation on exports"><h2>Documentation on exports</h2><div><div class="lpdoc-defname"><span class="lpdoc-predtag">REGTYPE</span><a class="lpdoc-idx-anchor" id="modulename/1" href="ciaosearch.html#modulename/1">modulename/1</a></div><div class="lpdoc-deftext">A module name is an atom, not containing characters `:&apos; or `$&apos;. Also, <tt>user</tt> and <tt>multifile</tt> are reserved, as well as the module names of all builtin modules (because in an executable all modules must have distinct names).<p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>modulename(M)</tt> </span><p><span class="lpdoc-var">M</span> is a module name (an atom).</p><ul class="lpdoc-itemize-minus"></ul></div></div><p> </div><div id="Documentation on internals"><h2>Documentation on internals</h2><div><div class="lpdoc-defname"><span class="lpdoc-predtag">DECLARATION</span><a class="lpdoc-idx-anchor" id="module/3" href="ciaosearch.html#module/3">module/3</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl">:- <tt>module(Name,Exports,Packages)</tt>. </span><p>Declares a module of name <span class="lpdoc-var">Name</span> which exports the predicates in <span class="lpdoc-var">Exports</span>, and uses the packages in <span class="lpdoc-var">Packages</span>. <span class="lpdoc-var">Name</span> must match with the name of the file where the module resides, without extension. For each source in <span class="lpdoc-var">Packages</span>, a <a class="lpdoc-idx-anchor" id="24" href="ciaosearch.html#package file">package file</a> is used. If the source is specified with a <a class="lpdoc-idx-anchor" id="25" href="ciaosearch.html#path alias">path alias</a>, this is the file included, if it is an atom, the library paths are searched. See <a class="lpdoc-idx-anchor" id="26" href="packages.html#package/1"><tt>package/1</tt></a> for a brief description of package files.<p>This directive must appear the first in the file.<p>Also, if the compiler finds an unknown declaration as the first term in a file, the name of the declaration is regarded as a package library to be included, and the arguments of the declaration (if present) are interpreted like the arguments of <a class="lpdoc-idx-anchor" id="27" href="#module/3"><tt>module/3</tt></a>.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="28" href="#modulename/1"><tt>modules:modulename/1</tt></a>)</span><span><span class="lpdoc-var">Name</span> is a module name (an atom). </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="29" href="basic_props.html#list/2"><tt>basic_props:list/2</tt></a>)</span><span><span class="lpdoc-var">Exports</span> is a list of <span class="lpdoc-var">predname</span>s. </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="30" href="basic_props.html#list/2"><tt>basic_props:list/2</tt></a>)</span><span><span class="lpdoc-var">Packages</span> is a list of <span class="lpdoc-var">sourcename</span>s. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">DECLARATION</span><a class="lpdoc-idx-anchor" id="module/2" href="ciaosearch.html#module/2">module/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl">:- <tt>module(Name,Exports)</tt>. </span><p>Same as directive <a class="lpdoc-idx-anchor" id="31" href="#module/3"><tt>module/3</tt></a>, with an implicit package <tt>default</tt>. This default package provides all the standard features provided by most Prolog systems so that Prolog programs with traditional <a class="lpdoc-idx-anchor" id="32" href="#module/2"><tt>module/2</tt></a> declarations can run without any change. See <a href="classic_doc.html">Classic Prolog</a>.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="33" href="#modulename/1"><tt>modules:modulename/1</tt></a>)</span><span><span class="lpdoc-var">Name</span> is a module name (an atom). </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="34" href="basic_props.html#list/2"><tt>basic_props:list/2</tt></a>)</span><span><span class="lpdoc-var">Exports</span> is a list of <span class="lpdoc-var">predname</span>s. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">DECLARATION</span><a class="lpdoc-idx-anchor" id="use_package/1" href="ciaosearch.html#use_package/1">use_package/1</a></div><div class="lpdoc-deftext"><span class="lpdoc-usage-decl">:- <tt>use_package(Package)</tt>. </span><p>Specifies the use in this file of the packages defined in <span class="lpdoc-var">Package</span>. See the description of the third argument of <a class="lpdoc-idx-anchor" id="35" href="#module/3"><tt>module/3</tt></a> for an explanation of <a class="lpdoc-idx-anchor" id="36" href="ciaosearch.html#package file">package file</a>s.<p>This directive must appear the first in the file, or just after a <a class="lpdoc-idx-anchor" id="37" href="#module/3"><tt>module/3</tt></a> declaration. A file with no module declaration, in the absence of this directive, uses an implicit package <tt>default</tt> (see <span class="lpdoc-missing">Other predicates and features defined by default</span>).<p><span class="lpdoc-usage-header">Usage 1:</span><span class="lpdoc-usage-decl">:- <tt>use_package(Package)</tt>. </span><p></p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="38" href="stream_basic.html#sourcename/1"><tt>stream_basic:sourcename/1</tt></a>)</span><span><span class="lpdoc-var">Package</span> is a source name. </span> </ul><p><span class="lpdoc-usage-header">Usage 2:</span><span class="lpdoc-usage-decl">:- <tt>use_package(Package)</tt>. </span><p></p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="39" href="basic_props.html#list/2"><tt>basic_props:list/2</tt></a>)</span><span><span class="lpdoc-var">Package</span> is a list of <span class="lpdoc-var">sourcename</span>s. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">DECLARATION</span><a class="lpdoc-idx-anchor" id="use_module/2" href="ciaosearch.html#use_module/2">use_module/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl">:- <tt>use_module(Module,Imports)</tt>. </span><p>Specifies that this code imports from the module defined in <span class="lpdoc-var">Module</span> the predicates in <span class="lpdoc-var">Imports</span>. The imported predicates must be exported by the other module.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="40" href="stream_basic.html#sourcename/1"><tt>stream_basic:sourcename/1</tt></a>)</span><span><span class="lpdoc-var">Module</span> is a source name. </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="41" href="basic_props.html#list/2"><tt>basic_props:list/2</tt></a>)</span><span><span class="lpdoc-var">Imports</span> is a list of <span class="lpdoc-var">predname</span>s. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">DECLARATION</span><a class="lpdoc-idx-anchor" id="use_module/1" href="ciaosearch.html#use_module/1">use_module/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl">:- <tt>use_module(Module)</tt>. </span><p>Specifies that this code imports from the module defined in <span class="lpdoc-var">Module</span> all the predicates exported by it. The previous version with the explicit import list is preferred to this as it minimizes the chances to have to recompile this code if the other module changes.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="42" href="stream_basic.html#sourcename/1"><tt>stream_basic:sourcename/1</tt></a>)</span><span><span class="lpdoc-var">Module</span> is a source name. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">DECLARATION</span><a class="lpdoc-idx-anchor" id="import/2" href="ciaosearch.html#import/2">import/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl">:- <tt>import(Module,Imports)</tt>. </span><p>Declares that this code imports from the module with name <span class="lpdoc-var">Module</span> the predicates in <span class="lpdoc-var">Imports</span>.<p><strong>Important note:</strong> this declaration is intended to be used when the current module or the imported module is going to be dynamically loaded, and so the compiler does not include the code of the imported module in the current executable (if only because the compiler cannot know the location of the module file at the time of compilation). For the same reason the predicates imported are not checked to be exported by <span class="lpdoc-var">Module</span>. Its use in other cases is strongly discouraged, as it disallows many compiler optimizations.<p>This is an example of such a case for a dynamically loaded module:<p><pre class="lpdoc-codeblock">:- module(_,_). :- import(bar,[b/1]). main(X) :- use_module(bar), b(X). </pre> </p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="43" href="#modulename/1"><tt>modules:modulename/1</tt></a>)</span><span><span class="lpdoc-var">Module</span> is a module name (an atom). </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="44" href="basic_props.html#list/2"><tt>basic_props:list/2</tt></a>)</span><span><span class="lpdoc-var">Imports</span> is a list of <span class="lpdoc-var">predname</span>s. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">DECLARATION</span><a class="lpdoc-idx-anchor" id="reexport/2" href="ciaosearch.html#reexport/2">reexport/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl">:- <tt>reexport(Module,Preds)</tt>. </span><p>Specifies that this code reexports from the module defined in <span class="lpdoc-var">Module</span> the predicates in <span class="lpdoc-var">Preds</span>. This implies that this module imports from the module defined in <span class="lpdoc-var">Module</span> the predicates in <span class="lpdoc-var">Preds</span>, an also that this module exports the predicates in <span class="lpdoc-var">Preds</span> .</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="45" href="stream_basic.html#sourcename/1"><tt>stream_basic:sourcename/1</tt></a>)</span><span><span class="lpdoc-var">Module</span> is a source name. </span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="46" href="basic_props.html#list/2"><tt>basic_props:list/2</tt></a>)</span><span><span class="lpdoc-var">Preds</span> is a list of <span class="lpdoc-var">predname</span>s. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">DECLARATION</span><a class="lpdoc-idx-anchor" id="reexport/1" href="ciaosearch.html#reexport/1">reexport/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl">:- <tt>reexport(Module)</tt>. </span><p>Specifies that this code reexports from the module defined in <span class="lpdoc-var">Module</span> all the predicates exported by it. This implies that this module imports from the module defined in <span class="lpdoc-var">Module</span> all the predicates exported by it, an also that this module exports all such predicates .</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="47" href="stream_basic.html#sourcename/1"><tt>stream_basic:sourcename/1</tt></a>)</span><span><span class="lpdoc-var">Module</span> is a source name. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">DECLARATION</span><a class="lpdoc-idx-anchor" id="ensure_loaded/1" href="ciaosearch.html#ensure_loaded/1">ensure_loaded/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><span class="lpdoc-on-right"><span class="lpdoc-iso">ISO</span></span><span>:- <tt>ensure_loaded(File)</tt>.</span> </span><p>Specifies that the code present in <span class="lpdoc-var">File</span> will be included in the executable being prepared, in the <tt>user</tt> module. The file <span class="lpdoc-var">File</span> cannot have a module declaration. This directive is intended to be used by programs not divided in modules. Dividing programs into modules is however strongly encouraged, since most of the attractive features of Ciao (such as static debugging and global optimization) are only partially available for <tt>user</tt> modules.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="48" href="stream_basic.html#sourcename/1"><tt>stream_basic:sourcename/1</tt></a>)</span><span><span class="lpdoc-var">File</span> is a source name. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">DECLARATION</span><a class="lpdoc-idx-anchor" id="include/1" href="ciaosearch.html#include/1">include/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><span class="lpdoc-on-right"><span class="lpdoc-iso">ISO</span></span><span>:- <tt>include(File)</tt>.</span> </span><p>The contents of the file <span class="lpdoc-var">File</span> are included in the current program text exactly as if they had been written in place of this directive.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="49" href="stream_basic.html#sourcename/1"><tt>stream_basic:sourcename/1</tt></a>)</span><span><span class="lpdoc-var">File</span> is a source name. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">DECLARATION</span><a class="lpdoc-idx-anchor" id="export/1" href="ciaosearch.html#export/1">export/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage 1:</span><span class="lpdoc-usage-decl">:- <tt>export(Pred)</tt>. </span><p>Adds <span class="lpdoc-var">Pred</span> to the set of exported predicates.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="50" href="basic_props.html#predname/1"><tt>basic_props:predname/1</tt></a>)</span><span><span class="lpdoc-var">Pred</span> is a predicate name. </span> </ul><p><span class="lpdoc-usage-header">Usage 2:</span><span class="lpdoc-usage-decl">:- <tt>export(Exports)</tt>. </span><p>Adds <span class="lpdoc-var">Exports</span> to the set of exported predicates.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="51" href="basic_props.html#list/2"><tt>basic_props:list/2</tt></a>)</span><span><span class="lpdoc-var">Exports</span> is a list of <span class="lpdoc-var">predname</span>s. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">DECLARATION</span><a class="lpdoc-idx-anchor" id="multifile/1" href="ciaosearch.html#multifile/1">multifile/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><span class="lpdoc-on-right"><span class="lpdoc-iso">ISO</span></span><span>:- <tt>multifile Predicates</tt>.</span> </span><p>Specifies that each predicate in <span class="lpdoc-var">Predicates</span> may have clauses in more than one file. Each file that contains clauses for a <a class="lpdoc-idx-anchor" id="52" href="ciaosearch.html#multifile predicate">multifile predicate</a> 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.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="53" href="basic_props.html#sequence_or_list/2"><tt>basic_props:sequence_or_list/2</tt></a>)</span><span><span class="lpdoc-var">Predicates</span> is a sequence or list of <span class="lpdoc-var">predname</span>s. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">DECLARATION</span><a class="lpdoc-idx-anchor" id="meta_predicate/1" href="ciaosearch.html#meta_predicate/1">meta_predicate/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl">:- <tt>meta_predicate MetaSpecs</tt>. </span><p>Specifies that the predicates in <span class="lpdoc-var">MetaSpecs</span> have arguments which have to be module expanded (predicates, goals, etc). <a class="lpdoc-idx-anchor" id="54" href="#meta_predicate/1"><tt>meta_predicate/1</tt></a> directives are only mandatory for exported predicates (in modules). This directive is defined as a prefix operator in the compiler.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="55" href="basic_props.html#sequence/2"><tt>basic_props:sequence/2</tt></a>)</span><span><span class="lpdoc-var">MetaSpecs</span> is a sequence of <span class="lpdoc-var">metaspec</span>s. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">DECLARATION</span><a class="lpdoc-idx-anchor" id="redefining/1" href="ciaosearch.html#redefining/1">redefining/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl">:- <tt>redefining(Predicate)</tt>. </span><p>Specifies that this module redefines predicate <span class="lpdoc-var">Predicate</span>, also imported from other module, or imports it from more than one module. This prevents the compiler giving warnings about redefinitions of that predicate. <span class="lpdoc-var">Predicate</span> can be partially (or totally) uninstantiated, to allow disabling those warnings for several (or all) predicates at once.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="56" href="basic_props.html#compat/2"><tt>basic_props:compat/2</tt></a>)</span><span><span class="lpdoc-var">predname</span> is <em>compatible</em> with <span class="lpdoc-var">Predicate</span>. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">DECLARATION</span><a class="lpdoc-idx-anchor" id="discontiguous/1" href="ciaosearch.html#discontiguous/1">discontiguous/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><span class="lpdoc-on-right"><span class="lpdoc-iso">ISO</span></span><span>:- <tt>discontiguous Predicates</tt>.</span> </span><p>Specifies that each predicate in <span class="lpdoc-var">Predicates</span> 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 <a class="lpdoc-idx-anchor" id="57" href="ciaosearch.html#prolog flag">prolog flag</a> <em>discontiguous_warnings</em>). The directive should precede all clauses of the affected predicates. This directive is defined as a prefix operator in the compiler.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="58" href="basic_props.html#sequence_or_list/2"><tt>basic_props:sequence_or_list/2</tt></a>)</span><span><span class="lpdoc-var">Predicates</span> is a sequence or list of <span class="lpdoc-var">predname</span>s. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">DECLARATION</span><a class="lpdoc-idx-anchor" id="impl_defined/1" href="ciaosearch.html#impl_defined/1">impl_defined/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl">:- <tt>impl_defined(Predicates)</tt>. </span><p>Specifies that each predicate in <span class="lpdoc-var">Predicates</span> is <em>impl</em>icitly <em>defined</em> 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.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="59" href="basic_props.html#sequence_or_list/2"><tt>basic_props:sequence_or_list/2</tt></a>)</span><span><span class="lpdoc-var">Predicates</span> is a sequence or list of <span class="lpdoc-var">predname</span>s. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">REGTYPE</span><a class="lpdoc-idx-anchor" id="metaspec/1" href="ciaosearch.html#metaspec/1">metaspec/1</a></div><div class="lpdoc-deftext">A meta-predicate specification for a predicate is the functor of that predicate applied to terms which represent the kind of module expansion that should be applied to each argument. Possible contents are represented as:<p><dl> <p><dt><tt>?,+,-,_</tt><dd> These values denote that this argument is not module expanded.<p><dt><tt>goal</tt><dd> This argument will be a term denoting a goal (either a simple or complex one) which will be called. For commpatibility reasons it can be named as <tt>:</tt> as well.<p><dt><tt>clause</tt><dd> This argument will be a term denoting a clause.<p><dt><tt>fact</tt><dd> This argument should be instantiated to a term denoting a fact (head-only clause).<p><dt><tt>spec</tt><dd> This argument should be instantiated to a predicate name, as Functor/Arity.<p><dt><tt>pred(<em>N</em>)</tt><dd> This argument should be instantiated to a predicate construct to be called by means of a <tt>call/<em>N</em></tt> predicate call (see <a class="lpdoc-idx-anchor" id="60" href="hiord_rt.html#call/2"><tt>call/2</tt></a>).<p><dt><tt>list(<em>Meta</em>)</tt><dd> This argument should be instantiated to a list of terms as described by <em>Meta</em> (e.g. <tt>list(goal)</tt>).<p><dt><tt>addterm(Meta)</tt><dd> This argument should be instantiated to the meta-data specified by <em>Meta</em>, and an argument added after this one will carry the original data without module expansion. Not intended to be used by normal users.<p><dt><tt>addmodule(Meta)</tt><dd> This argument should be instantiated to the meta-data specified by <em>Meta</em>, and in an argument added after this one will be passed the calling module, for example to allow handling more involved meta-data by using conversion builtins. <tt>addmodule</tt> is an alias of <tt>addmodule(?)</tt>. Not intended to be used by normal users.<p></dl><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>metaspec(M)</tt> </span><p><span class="lpdoc-var">M</span> is a meta-predicate specification.</p><ul class="lpdoc-itemize-minus"></ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">DECLARATION</span><a class="lpdoc-idx-anchor" id="initialization/1" href="ciaosearch.html#initialization/1">initialization/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><span class="lpdoc-on-right"><span class="lpdoc-iso">ISO</span></span><span>:- <tt>initialization(Goal)</tt>.</span> </span><p><span class="lpdoc-var">Goal</span> 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 dependencies).</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="61" href="basic_props.html#cgoal/1"><tt>basic_props:cgoal/1</tt></a>)</span><span><span class="lpdoc-var">Goal</span> is a term which represents a goal, i.e., an atom or a structure. </span> </ul></div></div><p> <div><div class="lpdoc-defname"><span class="lpdoc-predtag">DECLARATION</span><a class="lpdoc-idx-anchor" id="on_abort/1" href="ciaosearch.html#on_abort/1">on_abort/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl">:- <tt>on_abort(Goal)</tt>. </span><p><span class="lpdoc-var">Goal</span> will be executed after an abort of the execution of any program containing the current code.</p><ul class="lpdoc-itemize-minus"><li><em>The following properties should hold at call time:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="62" href="basic_props.html#cgoal/1"><tt>basic_props:cgoal/1</tt></a>)</span><span><span class="lpdoc-var">Goal</span> is a term which represents a goal, i.e., an atom or a structure. </span> </ul></div></div><p> </div><div id="Documentation on imports"><h2>Documentation on imports</h2>This module has the following direct dependencies:<ul class="lpdoc-itemize-minus"><li><em>Packages:</em><br/><a class="lpdoc-idx-anchor" id="63" href="ciaosearch.html#prelude"><tt>prelude</tt></a>, <a class="lpdoc-idx-anchor" id="64" href="ciaosearch.html#initial"><tt>initial</tt></a>, <a class="lpdoc-idx-anchor" id="65" href="condcomp_doc.html"><tt>condcomp</tt></a>, <a class="lpdoc-idx-anchor" id="66" href="assertions_doc.html"><tt>assertions</tt></a>, <a class="lpdoc-idx-anchor" id="67" href="ciaosearch.html#assertions/assertions_basic"><tt>assertions/assertions_basic</tt></a>. </ul></div></div><div class="lpdoc-footer">Generated with LPdoc using Ciao</div></div><div class="lpdoc-clearer"></div></div></body></html>