Re: [eclipse-users] Disappearing attributes

From: Joachim Schimpf (Independent Contractor) <jschimpf_at_...5...>
Date: Tue, 04 Sep 2007 14:16:09 +0100
Malcolm Ryan wrote:
> Why do attributes go away when a variable is instantiated? It is very  
> annoying.

It is simply a consequence of the concept of logical variable.
A logical variable is a placeholder for a value, and as soon
as the value is filled in, there is no longer a variable (and
therefore no attributes).  This isn't only conceptually so, but
also implementation-wise (implying for instance that the attributes
can be garbage collected).

Before the attribute goes away, the attribute's unify-handler
has a last chance to look at the attribute and the value the
variable has been instantiated to. This is typically sufficient
for attributes that represent constraints on the variable.

However, attributes are just normal data structures. If you want to
retain them beyond the lifetime of their variable, you can simply
store them in some data structure, e.g. an array or list.  Then of
course you may have the issue of wanting to access the variable (or
the value, after instantiation) starting from the attribute structure,
but this can be solved simply by putting the variable itself as an
additional argument into the attribute structure.  You then effectively
use the attribute structure as a handle for the variable/value.


-- Joachim
Received on Tue Sep 04 2007 - 14:16:37 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:29 CEST