@ciao-lang/ts-ciao-interface
Version:
Simple Ciao interface for node.
53 lines • 15.3 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>Low-level attributed variables — 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="attr_doc.html">↑</a><a class="lpdoc-navbutton" href="attr_rt.html">←</a><a class="lpdoc-navbutton" href="foreign_interface_doc.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="ExtendLang.html">PART IV - Language extensions</a> »<br/> </li><li><a href="attr_doc.html">Attributed variables</a> »<br/> </li><li><a href=""><strong>Low-level attributed variables</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 exports">Documentation on exports</a></li><li><a href="#Documentation on multifiles">Documentation on multifiles</a></li><li><a href="#Documentation on imports">Documentation on imports</a></li><li><a href="#Other information">Other information</a></li></ul></div><div class="lpdoc-main"><div id=""><h1>Low-level attributed variables</h1><a class="lpdoc-idx-anchor" href="ciaosearch.html#attributes"></a>
<strong>Author(s):</strong> <a class="lpdoc-idx-anchor" id="Christian Holzbaur" href="ciaosearch.html#Christian Holzbaur">Christian Holzbaur</a>, <a class="lpdoc-idx-anchor" id="Daniel Cabeza" href="ciaosearch.html#Daniel Cabeza">Daniel Cabeza</a>, <a class="lpdoc-idx-anchor" id="Manuel Carro" href="ciaosearch.html#Manuel Carro">Manuel Carro</a>.<p>
<p><div class="lpdoc-note"> Direct usage of this module is discouraged. Prefer package <a class="lpdoc-idx-anchor" id="0" href="attr_doc.html"><tt>attr</tt></a>. </div> <p>These predicates allow the manipulation of <a class="lpdoc-idx-anchor" id="1" href="ciaosearch.html#attributed variables"><em>attributed variables</em></a>. Attributes are special terms which are attached to a (free) variable, and are hidden from the normal Prolog computation. They can only be treated by using the predicates below.<br/><div id="Usage and interface"><h2>Usage and interface</h2><div class="lpdoc-cartouche"><ul><li><strong>Library usage:</strong><br/><tt>:- use_module(engine(attributes)).</tt><li><strong>Exports:</strong><br/><ul class="lpdoc-itemize-minus"><li><em>Predicates:</em><br/><a class="lpdoc-idx-anchor" id="2" href="#attach_attribute/2"><tt>attach_attribute/2</tt></a>, <a class="lpdoc-idx-anchor" id="3" href="#get_attribute/2"><tt>get_attribute/2</tt></a>, <a class="lpdoc-idx-anchor" id="4" href="#update_attribute/2"><tt>update_attribute/2</tt></a>, <a class="lpdoc-idx-anchor" id="5" href="#detach_attribute/1"><tt>detach_attribute/1</tt></a>.
<li><em>Multifiles:</em><br/><a class="lpdoc-idx-anchor" id="6" href="#verify_attribute/2"><tt>verify_attribute/2</tt></a>, <a class="lpdoc-idx-anchor" id="7" href="#combine_attributes/2"><tt>combine_attributes/2</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">PREDICATE</span><a class="lpdoc-idx-anchor" id="attach_attribute/2" href="ciaosearch.html#attach_attribute/2">attach_attribute/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>attach_attribute(Var,Attr)</tt>
</span><p>Attach attribute <span class="lpdoc-var">Attr</span> to <span class="lpdoc-var">Var</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="8" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">Var</span> is a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="9" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Attr</span> is currently a term which is not a free variable.
</span>
<li><em>The following properties hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="10" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">Var</span> is a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="11" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Attr</span> is currently a term which is not a free variable.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="get_attribute/2" href="ciaosearch.html#get_attribute/2">get_attribute/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>get_attribute(Var,Attr)</tt>
</span><p>Unify <span class="lpdoc-var">Attr</span> with the attribute of <span class="lpdoc-var">Var</span>, or fail if <span class="lpdoc-var">Var</span> has no attribute.</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="12" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">Var</span> is a free variable.
</span>
<li><em>The following properties hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="13" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Attr</span> is currently a term which is not a free variable.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="update_attribute/2" href="ciaosearch.html#update_attribute/2">update_attribute/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>update_attribute(Var,Attr)</tt>
</span><p>Change the attribute of attributed variable <span class="lpdoc-var">Var</span> to <span class="lpdoc-var">Attr</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="14" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">Var</span> is a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="15" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Attr</span> is currently a term which is not a free variable.
</span>
<li><em>The following properties hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="16" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">Var</span> is a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="17" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Attr</span> is currently a term which is not a free variable.
</span>
</ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="detach_attribute/1" href="ciaosearch.html#detach_attribute/1">detach_attribute/1</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>detach_attribute(Var)</tt>
</span><p>Take out the attribute from the attributed variable <span class="lpdoc-var">Var</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="18" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">Var</span> is a free variable.
</span>
<li><em>The following properties hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="19" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">Var</span> is a free variable.
</span>
</ul></div></div><p>
</div><div id="Documentation on multifiles"><h2>Documentation on multifiles</h2><div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="verify_attribute/2" href="ciaosearch.html#verify_attribute/2">verify_attribute/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>verify_attribute(Attr,Term)</tt>
</span><p><em>A user defined predicate.</em> This predicate is called when an attributed variable with attribute <span class="lpdoc-var">Attr</span> is about to be unified with the non-variable term <span class="lpdoc-var">Term</span>. The user should define this predicate (as multifile) in the modules implementing special unification.</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="20" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Attr</span> is currently a term which is not a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="21" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Term</span> is currently a term which is not a free variable.
</span>
<li><em>The following properties hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="22" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Attr</span> is currently a term which is not a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="23" href="term_typing.html#nonvar/1"><tt>term_typing:nonvar/1</tt></a>)</span><span><span class="lpdoc-var">Term</span> is currently a term which is not a free variable.
</span>
</ul>
The predicate is <em>multifile</em>.<br/></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="combine_attributes/2" href="ciaosearch.html#combine_attributes/2">combine_attributes/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>combine_attributes(Var1,Var2)</tt>
</span><p><em>A user defined predicate.</em> This predicate is called when two attributed variables with attributes <span class="lpdoc-var">Var1</span> and <span class="lpdoc-var">Var2</span> are about to be unified. The user should define this predicate (as multifile) in the modules implementing special unification.</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="24" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">Var1</span> is a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="25" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">Var2</span> is a free variable.
</span>
<li><em>The following properties hold upon exit:</em><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="26" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">Var1</span> is a free variable.
</span><br/><span class="lpdoc-on-right"> (<a class="lpdoc-idx-anchor" id="27" href="term_typing.html#var/1"><tt>term_typing:var/1</tt></a>)</span><span><span class="lpdoc-var">Var2</span> is a free variable.
</span>
</ul>
The predicate is <em>multifile</em>.<br/></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="28" href="ciaosearch.html#prelude"><tt>prelude</tt></a>, <a class="lpdoc-idx-anchor" id="29" href="ciaosearch.html#initial"><tt>initial</tt></a>, <a class="lpdoc-idx-anchor" id="30" href="condcomp_doc.html"><tt>condcomp</tt></a>, <a class="lpdoc-idx-anchor" id="31" href="assertions_doc.html"><tt>assertions</tt></a>, <a class="lpdoc-idx-anchor" id="32" href="ciaosearch.html#assertions/assertions_basic"><tt>assertions/assertions_basic</tt></a>, <a class="lpdoc-idx-anchor" id="33" href="ciaosearch.html#nortchecks"><tt>nortchecks</tt></a>.
</ul></div><div id="Other information"><h2>Other information</h2>
Note that <a class="lpdoc-idx-anchor" id="34" href="#combine_attributes/2"><tt>combine_attributes/2</tt></a> and <a class="lpdoc-idx-anchor" id="35" href="#verify_attribute/2"><tt>verify_attribute/2</tt></a> are not called with the attributed variables involved, but with the corresponding attributes instead. The reasons are:<p><ul> <p><li>There are simple applications which only refer to the attributes.<p><li>If the application wants to refer to the attributed variables themselves, they can be made part the attribute term. The implementation of <a class="lpdoc-idx-anchor" id="36" href="freeze.html#freeze/2"><tt>freeze/2</tt></a> utilizes this technique. Note that this does not lead to cyclic structures, as the connection between an attributed variable and its attribute is invisible to the pure parts of the Prolog implementation.<p><li>If attributed variables were passed as arguments, the user code would have to refer to the attributes through an extra call to <a class="lpdoc-idx-anchor" id="37" href="#get_attribute/2"><tt>get_attribute/2</tt></a>.<p><li>As the/one attribute is the first argument to each of the two predicates, indexing applies. Note that attributed variables themselves look like variables to the indexing mechanism.<p></ul> <p>However, future improvements may change or extend the interface to attributed variables in order to provide a richer and more expressive interface.<p>For customized output of attributed variables, please refer to the documentation of the predicate <a class="lpdoc-idx-anchor" id="38" href="write.html#portray_attribute/2"><tt>portray_attribute/2</tt></a>. <br/></div></div><div class="lpdoc-footer">Generated with LPdoc using Ciao</div></div><div class="lpdoc-clearer"></div></div></body></html>