Newsgroups: comp.lang.eiffel,comp.lang.ada,comp.lang.c++,comp.lang.smalltalk,comp.object
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!news.mathworks.com!hunter.premier.net!uunet!in2.uu.net!uucp4.uu.net!alexandria.organon.com!alexandria!jsa
From: jsa@alexandria (Jon S Anthony)
Subject: Re: OO, C++, and something much better!
In-Reply-To: James O'Connor's message of Sat, 25 Jan 1997 11:37:46 -0700
Message-ID: <JSA.97Jan27174711@alexandria>
Sender: news@organon.com (news)
Organization: Organon Motives, Inc.
References: <JSA.97Jan16141937@alexandria> <5buodl$bci@boursy.news.erols.com>
	<32E2FEC7.2F7B@concentric.net> <6PE5zLpF3RB@herold.franken.de>
	<32E8DC1C.4871@rase.com> <6PUKuJvV3RB@herold.franken.de>
	<32EA52FA.1CF9@jmpstart.com>
Date: Mon, 27 Jan 1997 22:47:11 GMT
Lines: 83
Xref: glinda.oz.cs.cmu.edu comp.lang.eiffel:17801 comp.lang.ada:56619 comp.lang.c++:243528 comp.lang.smalltalk:50144 comp.object:60407

In article <32EA52FA.1CF9@jmpstart.com> James O'Connor <joconnor@jmpstart.com> 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

