@ciao-lang/ts-ciao-interface
Version:
Simple Ciao interface for node.
3 lines • 11.8 kB
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>Basic concepts and conventions — 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">☰</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">↑</a><a class="lpdoc-navbutton" href="BasicLang.html">←</a><a class="lpdoc-navbutton" href="modules.html">→</a><a class="lpdoc-navbutton" href="ciaosearch.html">🔍</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> »<br/> </li><li><a href="BasicLang.html">PART II - The Ciao basic language</a> »<br/> </li><li><a href=""><strong>Basic concepts and conventions</strong></a></li></ul><hr></hr><em>ON THIS PAGE</em><ul><li><a href="#Syntax terminology and notational conventions">Syntax terminology and notational conventions</a></li><ul><li><a href="#Predicates and their components">Predicates and their components</a></li><li><a href="#Characters and character strings vs. atoms">Characters and character strings vs. atoms</a></li><li><a href="#Predicate specs">Predicate specs</a></li><li><a href="#Modes">Modes</a></li><li><a href="#Properties and types">Properties and types</a></li><li><a href="#Declarations">Declarations</a></li><li><a href="#Operators">Operators</a></li></ul></ul></div><div class="lpdoc-main"><div id=""><h1>Basic concepts and conventions</h1><a class="lpdoc-idx-anchor" href="ciaosearch.html#Conventions"></a>
<strong>Author(s):</strong> <a class="lpdoc-idx-anchor" id="The Ciao Development Team" href="ciaosearch.html#The Ciao Development Team">The Ciao Development Team</a>.<p>
<div id="Syntax terminology and notational conventions"><h2>Syntax terminology and notational conventions</h2> <a class="lpdoc-idx-anchor" id="0" href="ciaosearch.html#notation"></a> <p>Ciao is a language that has its roots in (and includes) the Prolog language. Thus, this manual assumes some familiarity with logic programming and Prolog. The reader is referred to standard textbooks on these topics (such as, e.g., [<a class="lpdoc-idx-anchor" id="1" href="ciaorefs.html#SterlingShapiro86">SS86</a>,<a class="lpdoc-idx-anchor" id="2" href="ciaorefs.html#Clome81">CM81</a>,<a class="lpdoc-idx-anchor" id="3" href="ciaorefs.html#apt-log-to-pl">Apt97</a>,<a class="lpdoc-idx-anchor" id="4" href="ciaorefs.html#Hogger84">Hog84</a>]) for background. However, we recall herein some concepts for the sake of establishing terminology. Also, we will briefly introduce some of the extensions that Ciao brings to the Prolog language that are instrumental for understanding this part of the manual.<p><div id="Predicates and their components"><h3>Predicates and their components</h3> <p>In logic programming <a class="lpdoc-idx-anchor" id="5" href="ciaosearch.html#procedures"><em>procedures</em></a> are also called <em>predicates</em> and <a class="lpdoc-idx-anchor" id="6" href="ciaosearch.html#procedure call sites"><em>procedure call sites</em></a> are also called <a class="lpdoc-idx-anchor" id="7" href="ciaosearch.html#literals"><em>literals</em></a>. Predicates are identified in this manual by the keyword 'PREDICATE' in the place where they are documented.<p>Program instructions are expressions made up of control constructs (<a href="basiccontrol.html">Control constructs/predicates</a>) and procedure calls (literals). These expressions are also called <a class="lpdoc-idx-anchor" id="8" href="ciaosearch.html#goals"><em>goals</em></a>. Literals are also (atomic) goals.<p>A <a class="lpdoc-idx-anchor" id="9" href="ciaosearch.html#predicate definition"><em>predicate definition</em></a> is a sequence of clauses. A <a class="lpdoc-idx-anchor" id="10" href="ciaosearch.html#clause"><em>clause</em></a> has the form ``<tt>H :- B.</tt>'' (ending in '<tt>.</tt>'), where <tt>H</tt> is syntactically the same as a literal and is called the clause <a class="lpdoc-idx-anchor" id="11" href="ciaosearch.html#head"><em>head</em></a>, and <tt>B</tt> is a comma separated list of literals (a conjunction) goal and is called the clause <em>body</em>. A clause with no body is written ``<tt>H.</tt>'' and is called a <a class="lpdoc-idx-anchor" id="12" href="ciaosearch.html#fact"><em>fact</em></a>. Clauses with body are also called <a class="lpdoc-idx-anchor" id="13" href="ciaosearch.html#rules"><em>rules</em></a>. A <a class="lpdoc-idx-anchor" id="14" href="ciaosearch.html#program"><em>program</em></a> is a sequence of predicate definitions.<p></div><div id="Characters and character strings vs. atoms"><h3>Characters and character strings vs. atoms</h3> <p>We adopt the following convention for representing character strings in the text of this manual: when a string is being used as an atom it is written thus: <tt>user</tt> or <tt>'user'</tt>; in all other circumstances double quotes are used (as in <tt>"hello"</tt>).<p></div><div id="Predicate specs"><h3>Predicate specs</h3> <p>Predicates are distinguished by their name <a class="lpdoc-idx-anchor" id="15" href="ciaosearch.html#predicate name"></a> <em>and</em> their <a class="lpdoc-idx-anchor" id="16" href="ciaosearch.html#arity"><em>arity</em></a> (number of arguments). We will call <tt>name/arity</tt> a <a class="lpdoc-idx-anchor" id="17" href="ciaosearch.html#<em>predicate spec</em>"><em><em>predicate spec</em></em></a>. Note that there can be predicates that have the same name and different arity. These are <em>different</em> predicates (conversely, they may of course have the same arity and different name). The notation <tt>name/arity</tt> is therefore used when it is necessary to refer to a predicate unambiguously. For example, <tt>concatenate/3</tt> specifies the predicate which is named ``concatenate'' and which takes 3 arguments.<p> </div><div id="Modes"><h3>Modes</h3> <p>When documenting a predicate, we will often describe how it is used with a <a class="lpdoc-idx-anchor" id="18" href="ciaosearch.html#mode spec"><em>mode spec</em></a> which has the form <tt>predicate(Arg1, ..., ArgN)</tt> where each <span class="lpdoc-var">Arg</span> may be preceded by a <a class="lpdoc-idx-anchor" id="19" href="ciaosearch.html#<em>mode</em>"><em><em>mode</em></em></a>. A mode is a functor which is wrapped around an argument (or prepended if defined as an operator). Such a mode allows documenting in a compact way the <a class="lpdoc-idx-anchor" id="20" href="ciaosearch.html#instantiation state"><em>instantiation state</em></a> on call and exit of the argument to which it is applied. The set of modes which can be used in Ciao is not fixed. Instead, arbitrary modes can be defined in programs by using the <a class="lpdoc-idx-anchor" id="21" href="assertions_doc.html#modedef/1"><tt>modedef/1</tt></a> declarations of the Ciao <a class="lpdoc-idx-anchor" id="22" href="ciaosearch.html#<em>assertion language</em>"><em>assertion language</em></a> (see <a href="assertions_doc.html">The Ciao assertion language</a> for details). Modes are identified in this manual by the keyword 'MODE'.<p>Herein, we will use the set of modes defined in the Ciao <a class="lpdoc-idx-anchor" id="23" href="isomodes_doc.html"><tt>isomodes</tt></a> library, which is essentially a precise definition of those used in the <a class="lpdoc-idx-anchor" id="24" href="ciaosearch.html#ISO-Prolog">ISO-Prolog</a> standard (<a href="isomodes_doc.html">ISO-Prolog modes</a>).<p></div><div id="Properties and types"><h3>Properties and types</h3> <p>Although Ciao is <em>not</em> a 'typed language,' it allows writing (and using) types, as well as more general <a class="lpdoc-idx-anchor" id="25" href="ciaosearch.html#<em>properties</em>"><em>properties</em></a>. These may be properties of states and properties of computations. Properties of state allow expressing characteristics of the program variables at particular points in the computation, like in <tt>sorted(X)</tt> (<tt>X</tt> is a sorted list). Properties of the computation allow expressing characteristics of a whole computation for a predicate, as in <tt>is_det(p(X,Y))</tt> (such calls yield only one solution). Properties are just a special form of predicates (<a href="regtypes_doc.html">Declaring regular types</a>) and are identified in this manual by the keyword 'PROPERTY'.<p>In Ciao types are a particular case of property. A frequently used library of types is <em>regular types</em> (<a href="regtypes_doc.html">Declaring regular types</a>). Properties of this kind are identified in this manual by the keyword 'REGTYPE'.<p></div><div id="Declarations"><h3>Declarations</h3> <p>A <em>declaration</em> provides information to one of the Ciao environment tools. Declarations are interspersed in the code of a program. The target tool can be the compiler (telling it that a predicate is dynamic, or a meta-predicate, etc.), the preprocessor (which understands declarations of properties and types, assertions, etc.), the autodocumenter (which understands the previous declarations and also certain ``comment'' declarations), or the debugger, among other tools.<p>A declaration has the form <tt>:- D.</tt> where <tt>D</tt> is syntactically the same as a literal. Declarations are identified in this manual by the keyword 'DECLARATION'.<p>In Ciao users can define (and document) new declarations. New declarations are typically useful when defining extensions to the language (which in Ciao are called packages). Such extensions are often implemented as <a class="lpdoc-idx-anchor" id="26" href="ciaosearch.html#expansions">expansions</a> (see <span class="lpdoc-missing">Extending the syntax</span>). There are many such extensions in Ciao. The <a class="lpdoc-idx-anchor" id="27" href="ciaosearch.html#functions"><tt>functions</tt></a> library, which provides fuctional syntax, is an example. The fact that in Ciao expansions are local to modules (as operators, see below) makes it possible to use a certain language extension in a module without affecting other modules.<p></div><div id="Operators"><h3>Operators</h3> <p>An <a class="lpdoc-idx-anchor" id="28" href="ciaosearch.html#operator">operator</a> is a functor (or predicate name) which has been declared as such, thus allowing its use in a prefix, infix, or suffix fashion, instead of the standard procedure-like fashion. E.g., declaring <tt>+</tt> as an infix operator allows writing <tt>X+Y</tt> instead of <tt>'+'(X,Y)</tt> (which may still, of course, be written).<p><em>Operators in Ciao are local to the module/file where they are declared</em>. At the same time, some operators are standard and are declared by default in every program (see <a href="operators.html">Defining operators</a>). This manual documents the operator declarations in each (library) module where they are included. As with expansions, the fact that in Ciao operators are local to modules makes it possible to use a certain language extension in one module without affecting other modules. </div></div><br/></div><div class="lpdoc-footer">Generated with LPdoc using Ciao</div></div><div class="lpdoc-clearer"></div></div></body></html>