comp.lang.ada
 help / color / mirror / Atom feed
From: noc.near.net!inmet!spock!stt@uunet.uu.net  (Tucker Taft)
Subject: Re: Ichibah flames, and flames out over, Ada 9X
Date: 11 Mar 93 15:13:25 GMT	[thread overview]
Message-ID: <1993Mar11.151325.10801@inmet.camb.inmet.com> (raw)

In article <1993Mar9.181231.27197@intellistor.com> 
  wicklund@intellistor.com (Tom Wicklund) writes:

>>How would you write this in a "class-based" language?
>>At least in C++, operators almost always have to be made "friends"
>>to work right.
>
>No they don't.  I suggest you look at the GNU g++ library
>implementation of complex, which I summarize below.  Note that there
>are NO friend functions.  

Thanks for pointing this out.  What I should have said
was that operators must generally *not* be member functions
if they are going to work right in conjunction with
implicit conversions.  As you illustrate, if the functionaliy
of a non-member-function operator can be expressed in terms
of some member function (operator or otherwise), then there
is no need to make the non-member-function operator a "friend."

Your example, however, illustrates the point I was *trying* (albeit
ineffectively ;-) to make, that the "encapsulation" provided
by a C++ class construct is not always complete, since one must revert
to non-member-function declarations (for example for many binary
operators) to get the desired functionality.  This is neither
good nor bad as far as I am concerned.  It just shows that a
"religious" belief that "class-based" languages (in as much
as C++ is one) do a better job of encapsulating all of the 
interesting operations "inside" the class, doesn't always 
turn out to be true.  However, by using files as modules, one
can get the logical grouping you desire in C++.

In Ada, the package provides all encapsulation, both for
the equivalent of member functions ("primitive subprograms" in
Ada 9X, "derivable subprograms" in Ada 83) and for any
associated types, operators, exceptions, generics, etc.
Either way works, but having *both* a class-based encapsulation
and a package-based encapsulation in a single language would
almost certainly result in undesirable complexity and confusion.

As far as the great "class" vs. "tagged" debate, Ada 9X does
have classes, and in fact the word "Class" appears quite prominently
in any Ada 9X example that uses polymorphism.  It just doesn't
happen to appear in the declaration of a tagged type.
Instead it appears in the declaration of polymorphic operations
and access types.  The concept of "class" is also behind the scenes 
any time you define a generic with a formal type 
like "type I is range <>;" since any type in the integer "class"
matches such a declaration (this is an example of compile-time
polymorphism).

As far as marketing to the masses, the big term these days 
is "object technology" not "class-based languages."
Given that, we should presume that Modula-3, since it uses
the term "object" in its syntax for OOP-related types, should
soon take over the world!  

One last note, before I retire from this debate, for the history buffs
who like to quote the computer science greats...

  One of the earlier places where the term "tag" appears in scholarly
  circles is in the classic book "Structured Programming" by
  O.-J. Dahl, E. W. Dijkstra, and C. A. R. Hoare.
  In Hoare's chapter entitled "Notes on Data Structuring,"
  in the section on "The Discriminated Union" he begins
  his subsection on "Manipulation" as follows:

     Any value of a discriminated union carries with it a "tag"
     field indicating which of the particular constituent types it
     originated from; on assignment this is copied, and on a test
     of equality, the tag fields must be the same if the values
     are to be equal.

  Hoare and Niklaus Wirth collaborated somewhat on the development
  of this concept, and "tag" was the term Wirth adopted in his
  description of Pascal (e.g. in the Pascal User Manual and Report).

  The term "tag" is also used in more recent "scholarly" contexts, 
  particularly in a paper on "Dynamic Typing in a Statically Typed 
  Language" by Abadi, Cardelli, Pierce, and Plotkin (TOPLAS 4/91).

Probably the major objection to the term "tagged" is that
it *sounds* too low-level and implementation oriented.  Of course,
some might find that comforting in a systems-programming language.
But even for those who prefer abstractness in a language, the
term "tagged" really just means "self-identifying."
Each "tagged" object in Ada 9X identifies its own underlying type.  
This is the key to run-time polymorphism, and is the critical step from
an abstraction-oriented language like Ada 83, to an "object"-oriented
language like Ada 9X.  In Ada 83, a given abstraction interface
has exactly one implementation.  In Ada 9X, as in other OOP languages,
a given interface may have many implementations, typically organized
into some kind of hierarchy.  The objects carry around an identifying
(abstract ;-) tag that allows them all to be manipulated through
a common interface, but still nevertheless to be treated specially
according to their self-identifying tag when appropriate, through
the "magic" of run-time dispatching.  Ada 83 already had abstract
data types (unlike C); they were called "private types."  In Ada 9X,
abstract data types are still called private types.  However, if
you want to use them with run-time polymorphism, then they have
to be "tagged" private types.  But they are still "private" types, 
and in many cases that is more fundamental than the fact
that they are "tagged."

So that's the technical/computer-science justification for the term.
As far as marketing, we do use the term "class" heavily in Ada 9X,
and we use it in a way that meshes nicely with its use in other
OO languages.  However, we made a judgement call that to use
it in the *syntax* of tagged types, and to call such types
"class types" would result in more problems (marketing and technical)
than it solved.

This judgement call was based on technical merit, on
marketing considerations, on usability, etc.  Of course, others
might reach a different conclusion (of course, others *have* reached
a different conclusion ;-).  Such is the way with language design.
You have to make some tough, but in many ways, "arbitrary" choices,
using the clearest "crystal ball" you can devise, and with an
eye toward the overall consistency and aesthetics of the language --
it is unwise to try to make one "corner" of the language "beautiful"
at the expense of overall consistency and usability.

In any case, it is quite unlikely that you will please everyone with
every design choice.  It is quite likely that there will be some vocal,
heartfelt, and well justified arguments on the opposite side of
almost every decision.  This particular choice seems to be
one of the "canonical" examples of that phenomenon.

But at some point, you make a decision and move on.  In this area,
we have done that, and only posterity will be able to confirm
whose "crystal ball" was clearer.  The only thing worth reiterating,
is that even if you don't agree with our decision, please believe
that we have the same technical, usability, and marketing concerns
as everyone who hopes that Ada 9X will be a widely-used, highly
productive programming language for developing and maintaining
the complex software systems of the 90's and beyond.

S. Tucker Taft   stt@inmet.com
Ada 9X Mapping/Revision Team
Intermetrics, Inc.
Cambridge, MA  02138

             reply	other threads:[~1993-03-11 15:13 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-03-11 15:13 Tucker Taft [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-03-10 20:39 Ichibah flames, and flames out over, Ada 9X John Goodsen
1993-03-10 20:15 John Goodsen
1993-03-10 22:41 ` David Emery
1993-03-12 16:01   ` Tom Pole
1993-03-12 22:59     ` Charles H. Sampson
1993-03-13  3:11     ` Keith Thompson @pulsar
1993-03-14 15:03       ` Fergus James HENDERSON
1993-03-15 23:19       ` Harry Koehnemann
1993-03-16  2:50         ` Michael Feldman
1993-03-17 18:18         ` Robert Firth
1993-03-12 22:02   ` Anthony Howell
1993-03-07 19:15 John Goodsen
1993-03-08  0:45 ` David Emery
1993-03-08 15:36 ` Tucker Taft
1993-03-08 16:28   ` Michael Feldman
1993-03-08 22:15     ` Gregory Aharonian
1993-03-09 14:20       ` Tucker Taft
1993-03-09 14:55         ` C. Michael Holloway
1993-03-10 14:51         ` Gregory Aharonian
1993-03-09 17:12       ` Harry Koehnemann
1993-03-09 20:54         ` Michael Feldman
1993-03-09 20:14       ` Larry M. Jordan
1993-03-09 17:49     ` Harry Koehnemann
1993-03-09 21:01       ` Michael Feldman
1993-03-09 18:12   ` Tom Wicklund
1993-03-09 18:53   ` Larry M. Jordan
1993-03-09 20:24     ` David Weller
1993-03-09 21:03       ` Michael Feldman
1993-03-12 14:49         ` Tucker Taft
1993-03-12 23:54           ` Michael Feldman
1993-03-16 17:34   ` Robert Firth
1993-02-26 22:58 Bob Munck
1993-02-28 18:42 ` Don Tyzuk
1993-03-04 22:44   ` news
1993-03-05  2:39     ` Richard Pattis
1993-03-05 11:36     ` David Weller
1993-03-05 12:06     ` Don Tyzuk
1993-02-26 16:26 enterpoop.mit.edu!linus!agate!howland.reston.ans.net!paladin.american.edu
1993-02-26 14:35 David Emery
1993-02-25 23:51 Mark A Biggar
1993-02-24 21:10 John Goodsen
1993-02-25  3:48 ` agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!ne
1993-02-25 17:08   ` Harry Koehnemann
1993-03-01 15:59     ` Tucker Taft
1993-03-02  7:43       ` Dag Bruck
1993-02-22 23:56 Robert I. Eachus
1993-02-22 19:32 asuvax!ennews!enuxhb.eas.asu.edu!koehnema
1993-02-17 14:50 agate!howland.reston.ans.net!wupost!darwin.sura.net!mlb.semi.harris.com!d
1993-02-17 11:54 agate!howland.reston.ans.net!sol.ctr.columbia.edu!The-Star.honeywell.com!
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox