Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!uxc.cso.uiuc.edu!uxc.cso.uiuc.edu!m.cs.uiuc.edu!p.cs.uiuc.edu!johnson From: johnson@p.cs.uiuc.edu Newsgroups: comp.lang.smalltalk Subject: Re: Smalltalk Types Message-ID: <80500074@p.cs.uiuc.edu> Date: 5 Sep 89 01:46:00 GMT References: <56930@aerospace.AERO.ORG> Lines: 50 Nf-ID: #R:aerospace.AERO.ORG:56930:p.cs.uiuc.edu:80500074:000:2239 Nf-From: p.cs.uiuc.edu!johnson Sep 4 20:46:00 1989 In my opinion, the following three definitions are equivalent. >By abbott@aerospace.aero.org (Russell J. Abbott) >In Smalltalk, a type is a set of "messages" that objects of that type >can receive. >By alan@ux.cs.man.ac.uk (Alan Wills) >Russ Abbott's one is a lot more useful: a type is the set of >objects that respond to a particular set of messages. >By cook@hplabsz.HPL.HP.COM (William Cook) >Types are abstract loose specifications that describe *what* messages an >object handles, not *how* it handles them. The first definition describes a type syntatically, i.e. it describes how you describe a type. The last two describe a type sematically, i.e. they describe the values in the type. All three are quite vague, as any one sentence definition must be. There has been a lot of work in the area of type systems for object-oriented languages. A type system where types are sets of operations (what I call signature types) is one way to go, and, in my opinion, is better than a type system that equates types and classes, such as that of C++, Eiffel, and Trellis/Owl. If you are inventing your own language then either of these two approaches will work. However, neither will work for Smalltalk. My paper in OOPSLA'86 describes why. >By rad@aragorn.cm.deakin.oz (Robert Dew) >Let O be the set of all objects. >Let M be the set of all messages. >Let S denote a subset of M. >Let T:O -> S be a mapping from an object to a set of all messages the object >understands. >Two objects o1 and o2 are of the same type iff > T(o1) = T(o2). I think that Robert's point is that objects with the same type must understand the identical set of messages. There is no reason to make this restriction. There is nothing wrong with saying that an object can be in many types at once. You can either say that an object is in many types or you can say that a function can take arguments that are in many types. As far as I know (which isn't very far), these two approaches give the same result. However, polymorphism is a fundamental characteristic of object-oriented languages in general and Smalltalk in particular, and you have to have some way of handling it. Ralph Johnson - University of Illinois at Urbana-Champaign