Xref: utzoo comp.lang.c++:3343 comp.lang.eiffel:192 comp.lang.smalltalk:1080 Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!brunix!bpe From: bpe@brunix (Page Elmore) Newsgroups: comp.lang.c++,comp.lang.eiffel,comp.lang.smalltalk Subject: Re: Use of inheritance for classification? Message-ID: <6685@brunix.UUCP> Date: 17 May 89 20:53:09 GMT References: <30582@apple.Apple.COM> <6365@brunix.UUCP> Sender: news@brunix.UUCP Reply-To: bpe@cs.brown.edu (Page Elmore) Organization: Brown University Department of Computer Science Lines: 38 If you have the types such as: Type Car ^ Property: color: allColors (type with instances of all colors) | Method: Paint(newColor: allColors) | | Type Honda CRX (inherits from Car) Property color: blueBlack (type with blue and black instances) where Type Car defines a property color which has as it's value type allColors and also has a method Paint which takes as its argument an instance of allcolors. Somewhere in the implementation of paint it sets the color of the car to the newly painted color -- an instance of allColors. Now what happens when someone invokes the Paint method with red as the argument on members of a set of Cars, some of which happen to also be Honda CRX's (this is invoking the rule that instances of the subtype are also instances of the supertype)? The Paint method will fail on those objects which are Honda CRX's. Now you will probably say that you should redefine Paint on Honda CRX as Paint(newColor:blueBlack) and only accept the correct colors. This only makes matters worse however because now you have "broken" the code which was trying to paint the set of cars (some of which are Honda's) some new color. You can cheat and have the Paint method just do nothing when the color is wrong, but then you are not building a strongly typed system (which is another discussion altogether). No matter how you do it, constraint of any of the signatures of a supertype in the subtype may "break" the implementation of the supertype or anything written to work on instances of the supertype. To me the modifications we term classification can be partitioned into two parts: one kind of modification which contains constraints like those above, and are modeled in systems such as the Semantic Data Model (Hammer and McLeod, ACM Trans on DBS, Sept, 1981), and the other which can be modeled with inheritance.