Oz and Mozart Users Mailing List

Re: Unification on stateless Objects?


From: Torsten Anders (t.anders@qub.ac.uk)
Date: Tue Jun 03 2003 - 19:19:12 CEST


On Tue, 2003-06-03 at 15:08, duchier@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@mozart-oz.org
and administriva mail to users-request@mozart-oz.org.
The Mozart Oz web site is at http://www.mozart-oz.org/.
Please send bug reports to bugs@mozart-oz.org.



This archive was generated by hypermail 2b29.