Oz and Mozart Users Mailing List

Re: Unification on stateless Objects?


From: duchier@ps.uni-sb.de
Date: Tue Jun 03 2003 - 16:08:50 CEST


t.anders@qub.ac.uk (Torsten Anders) writes:

> I just realised: unification does not work on objects, even if no state
> is involved (e.g. there are no class attributes, only features).

That is correct. The reason is that objects have token equality;
i.e. an object has identity. No amount of variable substitution can
change that.

> 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. Do
> I need to use records and build the means for inheritance myself?

First, you have to decide whether the kind of unification operation
that you want should work on objects which are not instances of
precisely the same class. I hope not. I don't see what it would mean
(suddenly an object would mutate from one class into another?).

If unification is restricted to instances of the same class, then here
is a simple design which indeed uses records: 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(...).

Cheers,

-- 
Denys Duchier - Équipe Calligramme - LORIA, Nancy, France
-
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.