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: 109fba,b87849933931bc93 X-Google-Attributes: gid109fba,public X-Google-Thread: fac41,b87849933931bc93 X-Google-Attributes: gidfac41,public X-Google-Thread: 103376,b87849933931bc93 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,b87849933931bc93 X-Google-Attributes: gid1108a1,public X-Google-Thread: 114809,b87849933931bc93 X-Google-Attributes: gid114809,public From: jsa@alexandria (Jon S Anthony) Subject: Re: OO, C++, and something much better! Date: 1997/01/27 Message-ID: #1/1 X-Deja-AN: 212719706 sender: news@organon.com (news) references: <5buodl$bci@boursy.news.erols.com> organization: Organon Motives, Inc. newsgroups: comp.lang.eiffel,comp.lang.ada,comp.lang.c++,comp.lang.smalltalk,comp.object Date: 1997-01-27T00:00:00+00:00 List-Id: In article <32EA52FA.1CF9@jmpstart.com> James O'Connor writes: > There are subtle differences between 'type', 'interface', and 'class' > and the terms get used somewhat interchangebly around here. Java, for Agreed. > example uses two separate constructs; Class (defining an interface and > and implementations) and Interface (describing only an interface). > 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...). In Ada, a type is definitely _not_ a kind of "datastructure". OTOH, I don't think that "interface" is a technical term in Ada - at least I can't find any definition of it. Well, there's package _interface_, but that has nothing to do with this discussion. In this context, I believe that Ada lingo would say that a _type_ defines an "interface" as the term is being used here, plus the set of legal values for that interface. If you want to dump this last bit (what the legal values are) into the notion of "interface", then it looks like a type simply defines an interface (this sounds kind of like the notion of a ADT as often given): RM 3.2 (1) A type is characterized by a set of values, and a set of primitive operations which implement the fundamental aspects of its semantics. An object of a given type is a run-time entity that contains (has) a value of the type. (2) Types are grouped into classes of types, reflecting the similarity of their values and primitive operations. There exist several language-defined classes of types (see NOTES below). Elementary types are those whose values are logically indivisible; composite types are those whose values are composed of component values. The "primitive operation" bit implicitly captures the part about being defined relative to a package specification (which is the only place that primitive operations can be defined) and the "packaged" whole is basically what other languages call a class (type conjoined with module) or (as in the Java case) you may need to toss in an implementation for the specification to complete the analogy. So (for Ada), I suppose you could say that an "interface" is an extra language thing meant to specify the semantics of something, that every type defines an interface and (possibly) any interface has a corresponding type which defines it. And the term "class" is used to denote a family of related types - related through type derivation. I find this use of the term "class" rather appealing as it adheres fairly close to what classification systems have always meant by "class". A class functions kinda sorta as a meta-type (and you can define extra operations for it as well). Also, a type does not provide or imply an implementation. It can be defined separately from any implementation and can be given several different implementations. > 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. Ada takes this a bit further: Technically, two objects _can't_ share the same set of method signatures (primitive operations) _unless_ they are of the _same_ type. Even if T2 is derived from T1, they are still two different types. But, they both belong to the same class of types and all the methods of T1 are (implicitly) declared for T2 with the signatures adjusted for T2. Of course any or all of these may be overridden for T2. In practice, things basically work as you would expect. /Jon -- Jon Anthony Organon Motives, Inc. Belmont, MA 02178 617.484.3383 jsa@organon.com