From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,b87849933931bc93 X-Google-Attributes: gidfac41,public X-Google-Thread: 1108a1,b87849933931bc93 X-Google-Attributes: gid1108a1,public X-Google-Thread: 109fba,b87849933931bc93 X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,b87849933931bc93 X-Google-Attributes: gid103376,public X-Google-Thread: 114809,b87849933931bc93 X-Google-Attributes: gid114809,public From: jhd@herold.franken.de (Joachim Durchholz) Subject: Re: OO, C++, and something much better! Date: 1997/01/26 Message-ID: <6PbObMf-3RB@herold.franken.de>#1/1 X-Deja-AN: 212361362 references: <6PE5zLpF3RB@herold.franken.de> newsgroups: comp.lang.eiffel,comp.lang.ada,comp.lang.c++,comp.lang.smalltalk,comp.object Date: 1997-01-26T00:00:00+00:00 List-Id: Arrgh, got a private copy before the news arrived, and my mailer is too dumb to redirect the private reply into the newsgroup... Well, I always wanted to cut&paste text screenful by screenful... here we go: > > I agree checking should be done on the interface, but I was not aware of > > any difference between type and interface. After all, objects with > > identical interface have the same type for all practical purposes. > > There are subtle differences between 'type', 'interface', and 'class' > and the terms get used somewhat interchangebly around here. I think these differences are mostly artificial. They have been introduced to capture subtle differences in the way languages implement various concepts. To my understanding, a class is a piece of program code, and an interface (or type) is everything that one must know to use that class. So an interface is a set of routine signatures and maybe class invariants, routine preconditions and routine postconditions. > Java, for > example uses two separate constructs; Class (defining an interface and > and implementations) and Interface (describing only an interface). A Java interface is just a shorthand for "class with nothing than an interface". A Java interface is not a general OO interface. Similar shorthands are known from other languages. C structures aren't full structure in a general sense, still I can talk about a structure containing fields and an application structure. I just have to make clear which sense is intended. > Ada95 (I think) uses the term type to mean a type of data tructure, the > type-and-package become what others call a class and the term 'Class' > means a family of types (I think this is right...). Types can be "opaque", meaning nothing about their internal structure is known to the outside world. (At least the original language had it this way, but I see no reason why they should have changed this.) I don't know anough of Ada95 to comment on the rest. > Smalltalk uses the > term 'class' to mean a class and the term 'type' to mean providing or > describing a certain interface. Well, then I'm a Smalltalker wrt. terminology... > However even type and interface are not > interchangble. In Java, two objects that happen to share the same set > of method signatures are not the same 'type' unless the inherit from a > common base Class or base Interface. There are two cases to distinguish here: 1) Signatures are the same, but there are observable differences in routine behaviour. In that case, the routines must do different things, which means they have different preconditions, different postconditions, or the classes have different invariants. 2) Signatures are the same, and there is no difference in routine behaviour. This case should be extremely rare though... and I'd consider them the same type, even if Java doesn't. > Deleting methods on the fly isn't very common. That was just an example. The same goes for changing signatures. > But delegation is, I > believe. If you use the #doesNotUnderstand: aMessage delagation > approach, than knowing the claass of an object may not tell you whether > a particular message send will work. Yup. But I don't think that this approach is too friendly to any attempt at compilation. But this is a totally different can of worms... enough! Regards, Joachim