Re: Derivation by restriction wrt to type inheritance

Henry S. Thompson <ht@cogsci.ed.ac.uk> writes:
>
> We started with some very simple invariants:
>
> Restriction:
>  instances of a restricted type is always an instances of the base type;
>
> Extension:
>  instances of an extended type always contain an instance of the base
>  type as a prefix.
>
> The latter is indeed modelled on sub-classing in OO languages.  Could
> you clarify your counter-example?  Certainly in C++ for instance basic
> derivation simply adds new instance variables/methods, it doesn't
> change those of the base, does it?  That's why you can always treat a
> pointer to an instance of the derived as an instance of the base,
> because on the stack it is actually realised as base+extras.
>

I think it is the same in Java, when you define a new class by derivation
and declare an instance variable with the same name as an instance variable
of the base type: depending on which type you cast a variable to, you can
access the object's instance variables. Imho it is not only a matter of what
programming languages allow you to do, it is also a matter of conceptual
modelling. I need some sort of covariant inheritance. My motivation for
redefining the type of an element in derivation by extension is that I want
to define the content model of instances at the meta type level.

Example: I have a meta type level (modelled with XML Schema) that defines a
List Type. Instances of lists must contain an "entry" element for each entry
(e.g. entry has type Object). Note that it is assured at the meta type level
that instances must have "entry" elemtns. At the type level (again XSD) I
define a Person List, or a list of whatever. A Person List's "entry"
elements are of type Person derived from Object.

For me there are two approaches:
a) Type level is an instance of the meta type level. This seems to be
complicated with XML Schema if the type level shall be an XML Schema
document again, because I can not restrict the usage of e.g. complex type in
settings where it is used to define e.g. a person list and not restrict it
in other cases.
b) Type level as derivation from the meta type level. Person List would be
derived from List Type, "restricting" the type of entry from e.g. Object to
Person. And here is the problem: I derive Person from Object by extension,
but would have to derive Person List from List Type by restriction to
redefine the type of the entry element, what is not possible.

When you say an extension has an instance of its base type as a prefix, this
(type redefinition) is of course not possible. Unfortunately therefore XML
Schema does not seem to be suited for my purpose.

Martin

Received on Monday, 26 November 2001 03:55:50 UTC