@ciao-lang/ts-ciao-interface
Version:
Simple Ciao interface for node.
12 lines • 6.79 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>Backtrackable global 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="ExtendLang.html">↑</a><a class="lpdoc-navbutton" href="dcg_phrase_doc.html">←</a><a class="lpdoc-navbutton" href="mutables.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=""><strong>Backtrackable global 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 imports">Documentation on imports</a></li></ul></div><div class="lpdoc-main"><div id=""><h1>Backtrackable global variables</h1><a class="lpdoc-idx-anchor" href="ciaosearch.html#global_vars"></a>
<strong>Author(s):</strong> <a class="lpdoc-idx-anchor" id="Jose F. Morales" href="ciaosearch.html#Jose F. Morales">Jose F. Morales</a>, <a class="lpdoc-idx-anchor" id="Remy Haemmerle" href="ciaosearch.html#Remy Haemmerle">Rémy Haemmerlé</a>.<p>
This module provides a simple way to assign and read fully backtrackable global variables.<p>Global variables differ from storing information using dynamic predicates: <ul> <li>Global variables are semantically equivalent to a dictionary passed around as an implicit pair of variables: <ul> <li>only one value is associated to a variable at a time <li>the value associated to a variable can be replaced <li>any assignment is undone on backtracking <li>access cost is proportional to a unification <li>variable sharing is preserved during assignment </ul> <li>Keys of global variables are local to each module. <li>Contrary to dynamic predicates, there is no copy of terms. This is particularly interesting for large terms. </ul> <p>The implementation is based on a globally reachable structure in the heap, where each entry is allocated dynamically for each key.<p>Note that the current implementation has some limitations (see bug entries in this module). <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(library(global_vars)).</tt><li><strong>Exports:</strong><br/><ul class="lpdoc-itemize-minus"><li><em>Predicates:</em><br/><a class="lpdoc-idx-anchor" id="0" href="#setval/2"><tt>setval/2</tt></a>, <a class="lpdoc-idx-anchor" id="1" href="#getval/2"><tt>getval/2</tt></a>, <a class="lpdoc-idx-anchor" id="2" href="#current/2"><tt>current/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="setval/2" href="ciaosearch.html#setval/2">setval/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>setval(Name,Value)</tt>
</span><p>Associate the term <span class="lpdoc-var">Value</span> with the atom <span class="lpdoc-var">Name</span>. If <span class="lpdoc-var">Name</span> does not refer to an existing global variable, an unbounded global variable <span class="lpdoc-var">Value</span> is created and unified to <span class="lpdoc-var">Value</span>. On backtracking the assignment is reversed. If <span class="lpdoc-var">Name</span> is not a atom the predicate silently fails.</p><ul class="lpdoc-itemize-minus"></ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="getval/2" href="ciaosearch.html#getval/2">getval/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>getval(Name,Value)</tt>
</span><p>Unifies <span class="lpdoc-var">Value</span> with the current value of the global variable refered to by the atom <span class="lpdoc-var">Name</span>. If <span class="lpdoc-var">Name</span> does not refer to an exisiting global variable, a free unbound variable is created and unified with <span class="lpdoc-var">Value</span>. If <span class="lpdoc-var">Name</span> is not an atom the predicate silently fails.</p><ul class="lpdoc-itemize-minus"></ul></div></div><p>
<div><div class="lpdoc-defname"><span class="lpdoc-predtag">PREDICATE</span><a class="lpdoc-idx-anchor" id="current/2" href="ciaosearch.html#current/2">current/2</a></div><div class="lpdoc-deftext"><p><span class="lpdoc-usage-header">Usage:</span><span class="lpdoc-usage-decl"><tt>current(Name,Value)</tt>
</span><p>Enumerate all defined variables with their value. The order of enumeration is undefined.</p><ul class="lpdoc-itemize-minus"></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>System library modules:</em><br/><a class="lpdoc-idx-anchor" id="3" href="datafacts_rt.html"><tt>datafacts_rt</tt></a>, <a class="lpdoc-idx-anchor" id="4" href="mutables.html"><tt>mutables</tt></a>.
<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="ciaosearch.html#hiord"><tt>hiord</tt></a>, <a class="lpdoc-idx-anchor" id="9" href="assertions_doc.html"><tt>assertions</tt></a>, <a class="lpdoc-idx-anchor" id="10" href="ciaosearch.html#assertions/assertions_basic"><tt>assertions/assertions_basic</tt></a>, <a class="lpdoc-idx-anchor" id="11" href="datafacts_doc.html"><tt>datafacts</tt></a>.
</ul></div></div><div class="lpdoc-footer">Generated with LPdoc using Ciao</div></div><div class="lpdoc-clearer"></div></div></body></html>