UNPKG

@ciao-lang/ts-ciao-interface

Version:

Simple Ciao interface for node.

32 lines (26 loc) 5.97 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>Block declarations &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="ExtendLang.html">&#x2191;</a><a class="lpdoc-navbutton" href="indexer_doc.html">&#x2190;</a><a class="lpdoc-navbutton" href="freeze.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="ExtendLang.html">PART IV - Language extensions</a> &raquo;<br/> </li><li><a href=""><strong>Block declarations</strong></a></li></ul><hr></hr><em>ON THIS PAGE</em><ul><li><a href="#Usage and interface">Usage and interface</a></li><li><a href="#Documentation on new declarations">Documentation on new declarations</a></li></ul></div><div class="lpdoc-main"><div id=""><h1>Block declarations</h1><a class="lpdoc-idx-anchor" href="ciaosearch.html#block"></a> <strong>Author(s):</strong> <a class="lpdoc-idx-anchor" id="Remy Haemmerle" href="ciaosearch.html#Remy Haemmerle">R&eacute;my Haemmerl&eacute;</a>, <a class="lpdoc-idx-anchor" id="Jose F. Morales" href="ciaosearch.html#Jose F. Morales">Jose F. Morales (documentation improvements)</a>.<p> <strong>Version:</strong> 0.1 (2008/25/5) This package provides compatibility with SICStus&apos; block declarations.<p><strong>Convention:</strong> The recommended style is to write the block declarations in front of the source code of the predicate they refer to. Indeed, they are part of the source code of the predicate and must precede the first clause. Moreover it is suggested to use <tt>?</tt> for specifying non conditioned arguments.<p><strong>Example:</strong> The following definition calls to <a class="lpdoc-idx-anchor" id="0" href="sets.html#merge/3"><tt>merge/3</tt></a> having uninstantiated arguments in the first and third position or in the second and third position will suspend.<p><pre class="lpdoc-codeblock">:- block merge(-,?,-), merge(?,-,-). merge([], Y, Y). merge(X, [], X). merge([H|X], [E|Y], [H|Z]) :- H @&lt; E, merge(X, [E|Y], Z). merge([H|X], [E|Y], [E|Z]) :- H @&gt;= E, merge([H|X], Y, Z). </pre> <p><strong>Simulating <tt>block</tt> with <a class="lpdoc-idx-anchor" id="1" href="when.html#when/2"><tt>when/2</tt></a> predicate</strong>: In the predicate above, execution of <tt>merge(X,Y,Z)</tt> is suspended while <tt>(var(X),var(Z);var(Y),var(Z))</tt> holds. A similar effect can be obtained with <a class="lpdoc-idx-anchor" id="2" href="when.html#when/2"><tt>when/2</tt></a> using the negated condition <tt>((nonvar(X);nonvar(Z)),(nonvar(Y);nonvar(Z)))</tt>.<p><pre class="lpdoc-codeblock">:- use_module(library(when)). merge(X,Y,Z) :- when(((nonvar(X);nonvar(Z)), (nonvar(Y);nonvar(Z))), merge_(X,Y,Z)). merge_([], Y, Y). merge_(X, [], X). merge_([H|X], [E|Y], [H|Z]) :- H @&lt; E, merge(X, [E|Y], Z). merge_([H|X], [E|Y], [E|Z]) :- H @&gt;= E, merge([H|X], Y, Z). </pre> <br/><div id="Usage and interface"><h2>Usage and interface</h2><div class="lpdoc-cartouche"><ul><li><strong>Library usage:</strong><br/><tt>:- use_package(block).</tt> or <tt>:- module(...,...,[block]).</tt><li><strong>New operators defined:</strong><br/><a class="lpdoc-idx-anchor" id="3" href="#block/1"><tt>block/1</tt></a> [1150,fx]. <li><strong>New declarations defined:</strong><br/><a class="lpdoc-idx-anchor" id="4" href="#block/1"><tt>block/1</tt></a>. <li><strong>Implicit imports:</strong><br/><ul class="lpdoc-itemize-minus"><li><em>Packages:</em><br/><a class="lpdoc-idx-anchor" id="5" href="ciaosearch.html#prelude"><tt>prelude</tt></a>, <a class="lpdoc-idx-anchor" id="6" href="ciaosearch.html#initial"><tt>initial</tt></a>, <a class="lpdoc-idx-anchor" id="7" href="condcomp_doc.html"><tt>condcomp</tt></a>, <a class="lpdoc-idx-anchor" id="8" href="assertions_doc.html"><tt>assertions</tt></a>, <a class="lpdoc-idx-anchor" id="9" href="ciaosearch.html#assertions/assertions_basic"><tt>assertions/assertions_basic</tt></a>. </ul></ul></div></div><div id="Documentation on new declarations"><h2>Documentation on new declarations</h2><div><div class="lpdoc-defname"><span class="lpdoc-predtag">DECLARATION</span><a class="lpdoc-idx-anchor" id="block/1" href="ciaosearch.html#block/1">block/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl">:- <tt>block(BlockSpecs)</tt>. </span><p><span class="lpdoc-var">BlockSpecs</span> specifies a disjunction of conditions. Each condition is of the form <tt>predname(C1, ..., CN)</tt> where each <span class="lpdoc-var">CI</span> is either a <tt>-</tt> if the call must suspend until the corresponding argument is bound, or anything else otherwise.</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="10" href="basic_props.html#sequence_or_list/2"><tt>basic_props:sequence_or_list/2</tt></a>)</span><span><span class="lpdoc-var">BlockSpecs</span> is a sequence or list of <span class="lpdoc-var">cgoal</span>s. </span> </ul></div></div><p> </div></div><div class="lpdoc-footer">Generated with LPdoc using Ciao</div></div><div class="lpdoc-clearer"></div></div></body></html>