Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > by-pkgid > 2fc07611b08d4a735fd34d5eb60d8e16 > files > 2206

ciao-1.10p8-3mdv2010.0.i586.rpm

<HTML>
<HEAD>
<!-- Created by texi2html 1.56k + clip patches and <A href="http://www.clip.dia.fi.upm.es/Software">lpdoc</A> from ciao.texi on 28 January 2007 -->

<LINK rel="stylesheet" href="ciao.css" type="text/css">
<TITLE>The Ciao Prolog System               - Attributed variables</TITLE>
</HEAD>
<BODY> 
Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_30.html">previous</A>, <A HREF="ciao_32.html">next</A>, <A HREF="ciao_241.html">last</A> section, <A HREF="ciao_toc.html">table of contents</A>.
<P><HR><P>


<H1><A NAME="SEC178" HREF="ciao_toc.html#TOC178">Attributed variables</A></H1>
<P>
<A NAME="IDX2120"></A>


<P>
<STRONG>Author(s):</STRONG> Christian Holzbaur, Daniel Cabeza, Manuel Carro.


<P>
<STRONG>Version:</STRONG> 1.10#7 (2006/4/26, 19:22:13 CEST)


<P>
<STRONG>Version of last change:</STRONG> 1.5#157 (2000/5/30, 13:4:47 CEST)


<P>
These predicates allow the manipulation of 
<A NAME="IDX2121"></A>
<A NAME="IDX2122"></A>
<EM>attributed variables</EM>. 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.



<UL>
<LI><A HREF="ciao_31.html#SEC179">Usage and interface (attributes)</A>
<LI><A HREF="ciao_31.html#SEC180">Documentation on exports (attributes)</A>
<LI><A HREF="ciao_31.html#SEC181">Documentation on multifiles (attributes)</A>
<LI><A HREF="ciao_31.html#SEC182">Other information (attributes)</A>
</UL>



<H2><A NAME="SEC179" HREF="ciao_toc.html#TOC179">Usage and interface (<CODE>attributes</CODE>)</A></H2>

<div class="cartouche">

<UL>

<LI><STRONG>Library usage:</STRONG>

These predicates are builtin in Ciao, so nothing special has to be done to use them.

<LI><STRONG>Exports:</STRONG>


<UL>

<LI><EM>Predicates:</EM>

<A NAME="IDX2123"></A>
<CODE>attach_attribute/2</CODE>, 
<A NAME="IDX2124"></A>
<CODE>get_attribute/2</CODE>, 
<A NAME="IDX2125"></A>
<CODE>update_attribute/2</CODE>, 
<A NAME="IDX2126"></A>
<CODE>detach_attribute/1</CODE>.

<LI><EM>Multifiles:</EM>

<A NAME="IDX2127"></A>
<CODE>verify_attribute/2</CODE>, 
<A NAME="IDX2128"></A>
<CODE>combine_attributes/2</CODE>.

</UL>

</UL>

</div class="cartouche">



<H2><A NAME="SEC180" HREF="ciao_toc.html#TOC180">Documentation on exports (<CODE>attributes</CODE>)</A></H2>
<P>
<A NAME="IDX2129"></A>
<A NAME="IDX2130"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>attach_attribute/2:</B>
<DD><A NAME="IDX2131"></A>


<P>
<STRONG>Usage:</STRONG> <CODE>attach_attribute(Var, Attr)</CODE>

<UL>
<LI><EM>Description:</EM> Attach attribute <CODE>Attr</CODE> to <CODE>Var</CODE>.

<LI><EM>The following properties should hold at call time:</EM>

<CODE>Var</CODE> is a free variable.
 (<CODE>term_typing:var/1</CODE>)

<CODE>Attr</CODE> is currently a term which is not a free variable.
 (<CODE>term_typing:nonvar/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX2132"></A>
<A NAME="IDX2133"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>get_attribute/2:</B>
<DD><A NAME="IDX2134"></A>


<P>
<STRONG>Usage:</STRONG> <CODE>get_attribute(Var, Attr)</CODE>

<UL>
<LI><EM>Description:</EM> Unify <CODE>Attr</CODE> with the attribute of <CODE>Var</CODE>, or fail if <CODE>Var</CODE> has no attribute.

<LI><EM>The following properties should hold at call time:</EM>

<CODE>Var</CODE> is a free variable.
 (<CODE>term_typing:var/1</CODE>)
<LI><EM>The following properties should hold upon exit:</EM>

<CODE>Attr</CODE> is currently a term which is not a free variable.
 (<CODE>term_typing:nonvar/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX2135"></A>
<A NAME="IDX2136"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>update_attribute/2:</B>
<DD><A NAME="IDX2137"></A>


<P>
<STRONG>Usage:</STRONG> <CODE>update_attribute(Var, Attr)</CODE>

<UL>
<LI><EM>Description:</EM> Change the attribute of attributed variable <CODE>Var</CODE> to <CODE>Attr</CODE>.

<LI><EM>The following properties should hold at call time:</EM>

<CODE>Var</CODE> is a free variable.
 (<CODE>term_typing:var/1</CODE>)

<CODE>Attr</CODE> is currently a term which is not a free variable.
 (<CODE>term_typing:nonvar/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX2138"></A>
<A NAME="IDX2139"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>detach_attribute/1:</B>
<DD><A NAME="IDX2140"></A>


<P>
<STRONG>Usage:</STRONG> <CODE>detach_attribute(Var)</CODE>

<UL>
<LI><EM>Description:</EM> Take out the attribute from the attributed variable <CODE>Var</CODE>.

<LI><EM>The following properties should hold at call time:</EM>

<CODE>Var</CODE> is a free variable.
 (<CODE>term_typing:var/1</CODE>)
</UL>

</DL>



<H2><A NAME="SEC181" HREF="ciao_toc.html#TOC181">Documentation on multifiles (<CODE>attributes</CODE>)</A></H2>
<P>
<A NAME="IDX2141"></A>
<A NAME="IDX2142"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>verify_attribute/2:</B>
<DD><A NAME="IDX2143"></A>


<P>
The predicate is <EM>multifile</EM>.


<P>
<STRONG>Usage:</STRONG> <CODE>verify_attribute(Attr, Term)</CODE>

<UL>
<LI><EM>Description:</EM> <EM>A user defined predicate.</EM> This predicate is called when an attributed variable with attribute <CODE>Attr</CODE> is about to be unified with the non-variable term <CODE>Term</CODE>. The user should define this predicate (as multifile) in the modules implementing special unification.

<LI><EM>The following properties should hold at call time:</EM>

<CODE>Attr</CODE> is currently a term which is not a free variable.
 (<CODE>term_typing:nonvar/1</CODE>)

<CODE>Term</CODE> is currently a term which is not a free variable.
 (<CODE>term_typing:nonvar/1</CODE>)
</UL>

</DL>

<P>
<A NAME="IDX2144"></A>
<A NAME="IDX2145"></A>
<DL>
<DT><span class="define">PREDICATE:</span> <B>combine_attributes/2:</B>
<DD><A NAME="IDX2146"></A>


<P>
The predicate is <EM>multifile</EM>.


<P>
<STRONG>Usage:</STRONG> <CODE>combine_attributes(Var1, Var2)</CODE>

<UL>
<LI><EM>Description:</EM> <EM>A user defined predicate.</EM> This predicate is called when two attributed variables with attributes <CODE>Var1</CODE> and <CODE>Var2</CODE> are about to be unified. The user should define this predicate (as multifile) in the modules implementing special unification.

<LI><EM>The following properties should hold at call time:</EM>

<CODE>Var1</CODE> is a free variable.
 (<CODE>term_typing:var/1</CODE>)

<CODE>Var2</CODE> is a free variable.
 (<CODE>term_typing:var/1</CODE>)
</UL>

</DL>



<H2><A NAME="SEC182" HREF="ciao_toc.html#TOC182">Other information (<CODE>attributes</CODE>)</A></H2>

<P>
Note that 
<A NAME="IDX2147"></A>
<CODE>combine_attributes/2</CODE> and 
<A NAME="IDX2148"></A>
<CODE>verify_attribute/2</CODE> are not called with the attributed variables involved, but with the corresponding attributes instead. The reasons are: 



<UL>

<LI>There are simple applications which only refer to the attributes.

<LI>If the application wants to refer to the attributed variables themselves, they can be made part the attribute term. The implementation of

<A NAME="IDX2149"></A>
<CODE>freeze/2</CODE> 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. 

<LI>If attributed variables were passed as arguments, the user code would have to refer to the attributes through an extra call to

<A NAME="IDX2150"></A>
<CODE>get_attribute/2</CODE>. 

<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.

</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 NAME="IDX2151"></A>
<CODE>portray_attribute/2</CODE>. 


<P><HR><P>
Go to the <A HREF="ciao_1.html">first</A>, <A HREF="ciao_30.html">previous</A>, <A HREF="ciao_32.html">next</A>, <A HREF="ciao_241.html">last</A> section, <A HREF="ciao_toc.html">table of contents</A>.
</BODY>
</HTML>