Re: local reference(+Name)

From: Joachim Schimpf <j.schimpf_at_icparc.ic.ac.uk>
Date: Wed 16 Mar 2005 05:00:52 PM GMT
Message-ID: <42386644.9090606@icparc.ic.ac.uk>
Ulrich Scholz wrote:
> Hi everybody.
> 
> I have two suggestions about references:
> 
> 
> 1) Currently, one can create a named reference with
> 
>     local reference(+Name).
> 
> that holds a reference to a term in the same way as a logical variable.  I
> would appreciate a local reference that can be used by handle.
> 
> ...
> 
> By now, I use a hash table with a single entry.

You can use a wrapper structure and setarg/3, e.g.

make_ref(ref(Init), Init).

update_ref(Ref, Value) :- setarg(1, Ref, Value).

get_ref(ref(Value), Value).


?- make_ref(R, hello), get_ref(R, Old), update_ref(R, there), get_ref(R, New).
R = ref(there)
Old = hello
New = there
Yes (0.00s cpu)


> 
> 
> 2) Maybe you should separate the description of named references from the
> description bags and stores in the user manual because the name of their
> "group" refers to non-logical predicates explicitly.

Yes, good idea.


-- 
  Joachim Schimpf              /             phone: +44 20 7594 8187
  IC-Parc                     /      mailto:J.Schimpf@imperial.ac.uk
  Imperial College London    /    http://www.icparc.ic.ac.uk/eclipse
Received on Wed Mar 16 17:02:43 2005

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:34 PM GMT GMT