<p>You can find one of the oldest and most elaborate implementations of attributed variables in <a href="http://eclipseclp.org">ECLiPSe</a>, where it forms part of the wider infrastructure for implementing constraint solvers.</p>

<p>The main characteristics of this design are:</p>

<ul>
<li>attributes must be declared, and in return the compiler supports efficient access</li>
<li>a syntax for attributed variables, so that they can be read and written</li>
<li>a more complete set of handlers for attribute operations, so that attributes are not only taken into account for unification, but also for other generic operations such as term copying and subsumption tests</li>
<li>a clear separation between the concepts of variable attribute and suspended goals</li>
<li>used in over a dozen of ECLiPSe's libraries</li>
</ul>

<p><a href="http://arxiv.org/abs/1012.4240">This paper (section 4)</a> and the ECLiPSe documentation have more details.</p>
Attributed variables: library interfaces / implementations / portability
<p>When I was skimming some <a href="/questions/tagged/prolog" class="post-tag" title="show questions tagged &#39;prolog&#39;" rel="tag">prolog</a> related questions recently, I stumbled upon <a href="https://stackoverflow.com/questions/10096124/how-to-represent-directed-cyclic-graph-in-prolog-with-direct-access-to-neighbour/10101483#10101483">this answer by @mat</a> to question <a href="https://stackoverflow.com/questions/10096124/how-to-represent-directed-cyclic-graph-in-prolog-with-direct-access-to-neighbour">How to represent directed cyclic graph in Prolog with direct access to neighbour verticies</a> .</p>

<p>So far, my personal experience with attributed variables in Prolog has been very limited. But the use-case given by @mat sparked my interest. So  I tried using it for answering another question, <a href="https://stackoverflow.com/questions/6214266/ordering-lists-with-constraint-logic-programming/29657722#29657722">ordering lists with constraint logic programming</a>.</p>

<p><em>First, the good news:</em> My first use of attributed variables worked out like I wanted it to.</p>

<p><em>Then, the not so good news:</em> When I had posted by answer, I realized there were several API's and implementations for attributed variables in Prolog.</p>

<p>I feel I'm over my head here... In particular I want to know the following:</p>

<ul>
<li>What API's are in wide-spread use? Up to now, I found two: SICStus and SWI.</li>
<li>Which features do the different attributed variable implementations offer? The same ones? Or does one subsume the other?</li>
<li>Are there differences in semantics?</li>
<li>What about the actual implementation? Are some more efficient than others?</li>
<li>Can be (or is) using attributed variables a portability issue?</li>
</ul>

<p>Lots of question marks, here... Please share your experience / stance? 
 Thank you in advance!</p>

<hr>

<h3>Edit 2015-04-22</h3>

<p>Here's a code snippet of the <a href="https://stackoverflow.com/questions/6214266/ordering-lists-with-constraint-logic-programming/29657722#29657722">answer</a> mentioned above:</p>

<pre><code>init_att_var(X,Z) :-
    put_attr(Z,value,X).

get_att_value(Var,Value) :-
    get_attr(Var,value,Value).
</code></pre>

<p>So far I "only" use <a href="http://www.swi-prolog.org/pldoc/man?section=attvar" rel="nofollow noreferrer"><code>put_attr/3</code> and <code>get_attr/3</code></a>, but---according to the SICStus Prolog documentation on attributed variables---SICStus offers <a href="https://sicstus.sics.se/sicstus/docs/latest4/html/sicstus.html/lib_002datts.html" rel="nofollow noreferrer"><code>put_attr/2</code> and <code>get_attr/2</code></a>.</p>

<p>So even <em>this very shallow use-case</em>  <em>requires</em> some <em>emulation</em> layer (one way or the other).</p>