Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!uw-june!rkr From: rkr@cs.washington.edu (R. K. Raj) Newsgroups: comp.lang.smalltalk Subject: Re: Smalltalk types Message-ID: <9138@june.cs.washington.edu> Date: 7 Sep 89 18:10:42 GMT References: <56929@aerospace.AERO.ORG> <7784@charlie.OZ> <7785@charlie.OZ> <9120@june.cs.washington.edu> <7792@charlie.OZ> Reply-To: rkr@june.cs.washington.edu.cs.washington.edu (R. K. Raj) Organization: Computer Science Department, U Wash in Sea Lines: 39 In <7792@charlie.OZ> rad@aragorn.UUCP (Robert Alan Dew) writes: >#> >#>Two objects o1 and o2 are of the same type iff >#> T(o1) = T(o2). ># >#The concept of conformity is useful in object-oriented languages in >#extending the notion of type equivalence. We should be interested in knowing >#when one object can be used in place of another. >#For instance, using the >#above notation, we can say that o1 can be used in place of o2 iff ># T(o1) is a superset of T(o2). > >I disagree. The definition for replacement must be stronger. >Care should be taken when o1 replaces o2, this is because o1 can have a >completely different behaviour when recieving the same message. > >The message does not imply the same behaviour for objects of the same type. > >Robert Dew rad@aragorn.cm.deakin.oz Notice that I only said that o1 can be used in place of o2 and did not guarantee that you'd get the same behavior. What one would like is to say that o1 can be used in place of o2 iff B(o1) is a superset of B(o2). (B = Behavior) Unfortunately, the problem is: how do you (or the compiler) figure out what is equivalent behavior? It therefore makes sense to relax the behavior requirement and accept the weaker requirement of mere conforming types. This isn't much different from what is done in more traditional languages. For example, when a procedure call such as SORT(A) is made in a Pascal program, there is no simple way of determining that the actual procedure body of SORT does what it is intuitively expected to do: all the programmer and the compiler do is to ensure that procedure call and procedure header interfaces match. While techniques based on program verification can be used, they typically are not used. Why? That's another story. - R. K. Raj rkr@cs.washington.edu, rkr@uw-june.UUCP