Unification on stateless Objects?

Torsten Anders t.anders at qub.ac.uk
Tue Jun 3 19:19:12 CEST 2003


On Tue, 2003-06-03 at 15:08, duchier at ps.uni-sb.de wrote:
> > I want to do unification on data which is organised in a data type
> > hierarchy, e.g., data types inherit data slots and functions/methods. 
> 
> create a name N for each
> such class (keep track of which corresponds to which).  Have e.g. a
> method pack($) which returns a record N(...)  containing the
> appropriate data.  Use this record for everything that involves
> unification.  To go in the other direction: given a record N(...),
> recognize that it corresponds to class C, create an instance of C
> initialized with N(...).

Just a slight variation of your proposal (thank you!), instead of using
names I just put the class itself in the record (if I change the state
of the class attributes unification stops of course):

class MyClass
   attr x 
   meth init(x:X<=_) @x = X end
   meth getX(?X) X=@x end
   meth toRecord(?X)
      X = myClass('class':MyClass x: @x)
   end
end
fun {ToObject R}
   {New R.'class' init(x:R.x)}
end
X Y C1 C2
C1 = {New MyClass init}
C2 = {New MyClass init}
% unify objects
{C1 toRecord($)} = {C2 toRecord($)}
C3 = {ToObject {C1 toRecord($)}}

Best,
Torsten


-
Please send submissions to users at mozart-oz.org
and administriva mail to users-request at mozart-oz.org.
The Mozart Oz web site is at http://www.mozart-oz.org/.
Please send bug reports to bugs at mozart-oz.org.





More information about the mozart-users mailing list