comp.lang.ada
 help / color / mirror / Atom feed
From: eachus@spectre.mitre.org (Robert I. Eachus)
Subject: Re: Eiffel and Java + Ada dispatching
Date: 1996/11/15
Date: 1996-11-15T00:00:00+00:00	[thread overview]
Message-ID: <EACHUS.96Nov15171435@spectre.mitre.org> (raw)
In-Reply-To: E0wEJo.Gpr@syd.csa.com.au



   I said:

   :   In Ada, the default for generics is that you get the "predefined"
   :operations for the class.  But if you explicitly pass the operation as
   :a generic formal, you can override the standard definition.  No
   :surprise there either.  

In article <E0wEJo.Gpr@syd.csa.com.au> donh@syd.csa.com.au (Don Harrison) writes:

  > Okay. If it made sense, I think I would prefer to encapsulate
  > behaviour of related operations into a type and define descendants
  > covering the variants.  Then the parent type bundled with its
  > operations can be used as a formal generic parameter. That way,
  > you simplify the generic interface. Don't know whether this fits
  > at all.

   Exactly, and that is the usual case.  But there are cases where you
want to have several very similar methods/functions/operations (choose
your term) that are slightly different.  In Ada you can do this
tailoring with generic formal subprogram parameters.  For a hackneyed
example say you want to write a Runge-Kutta integration routine.  It
is nice to be able to make it a generic (with respect to the type of
the integrand) and to call it with values for the function to be
integrated and the bounds.

   In Ada you get to choose between THREE places where parameters and
methods can be fixed:  At the point where generic definition appears,
at the point where the generic instantiation occurs, and at the point
of the call.  The "tricky bit" is that you can also have overridable
defaults bound at any of those three locations.  I don't know why you
would want to provide a RK routine where the default number of steps
was set during instantiation, but you can do it if you want to.

  > If you were writing this now in Ada95, would you be able to reduce
  > the complexity by using OO stuff?

   No, and no!  First, the complexity is not in the code, it is in the
understanding of the requirements.  Second, if those are the
requirements, the same solution is probably the simplest in Ada 83 and
Ada 95.

   This is a symptom of a general problem for OO programmers learning
Ada.  In Ada generics are often a much simpler, and hugely more
maintainable solution to many problems that can only be solved with
inheritance in other OO languages.  As a result in well written Ada 95
code, it is rare for a class to have grandchildren.  (Hmmm.  Better
stated as almost all grandchildren are descended from Controlled or
Limited_Controlled.)  But it is not uncommon for a derived tagged type
declaration to be followed by several generic instantiations that
would have be done in some other languages by multiple inheritance.

    My favorite illustration of this uses lists.  In Ada if you create
a class by specialization, and want to be able to make lists of the
members you will almost certainly use a generic.  In other languages
you would inherit from both the general class and a list class.

    Is this because you can't do it the other way?  No, it is because
it usually turns out to be cleaner to have both list objects and
objects which can be members of lists.  Ada makes it easy to do this,
and without loss of generality in the list class, so that is usually
the best way to do it.  (Why is it better to have two types?
Overloading again.  If the types are different, then it is possible to
provide (with one, one-line instantiation) among other operations:

     function "&" (L,R: Element) return List;
     function "&" (L: Element; R: List) return List;
     function "&" (L: List; R: Element) return List;
     function "&" (L,R: List) return List;

    ...and get the expected semantics.  If the types are the same,
then there is no way to distinguish between a list containing one
element and an element.

  > I'll interpret 'powerful' to mean 'esoteric'. :)

  No, I meant powerful.  Just like working with rocket fuel or
high-voltage electicity or what have you.  When you are working with
constructs where the change of one word, say a parameter name, can
have a global effect on modules which never use that name, you have to
use design principles and configuration manangement tools very
different from the run of the mill.

   (Just so I don't scare anyone off, what I usually do is when
overloading operations or overriding methods, I use the same parameter
names.  This makes it clear that you never intend to use parameter
names in overload resolution, just to match parameter values to
formals.)

--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




  reply	other threads:[~1996-11-15  0:00 UTC|newest]

Thread overview: 162+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-10-27  0:00 Eiffel and Java Vincent WEBER
1996-10-27  0:00 ` Jean-Michel P. Decombe
1996-10-28  0:00   ` David Hanley
1996-10-28  0:00     ` Matt Kennel
1996-10-28  0:00   ` Alexandre Oliva
1996-10-28  0:00   ` Robert Dewar
1996-10-31  0:00     ` Doug Marker
1996-10-29  0:00   ` Chris Trimble
1996-10-31  0:00     ` Doug Marker
1996-10-31  0:00   ` David Bennett
1996-10-28  0:00 ` Matthew Heaney
1996-10-29  0:00   ` Vincent WEBER
1996-10-31  0:00     ` James McKim
1996-11-01  0:00       ` Matthew Heaney
1996-11-04  0:00         ` James McKim
1996-10-30  0:00   ` Don Harrison
1996-10-31  0:00     ` James McKim
1996-11-04  0:00       ` Don Harrison
1996-11-23  0:00       ` Van Snyder
1996-10-30  0:00   ` Jon S Anthony
1996-11-01  0:00     ` Eiffel and Java + Ada dispatching Jean-Marc Jezequel
1996-10-31  0:00   ` Eiffel and Java Joachim Durchholz
1996-11-01  0:00   ` Norman H. Cohen
1996-11-02  0:00   ` Jon S Anthony
1996-11-02  0:00   ` Eiffel and Java + Ada dispatching Jon S Anthony
1996-11-03  0:00   ` Eiffel and Java Joachim Durchholz
1996-11-05  0:00   ` Norman H. Cohen
1996-10-28  0:00 ` Larry Kilgallen
1996-10-30  0:00   ` Ronald Cole
1996-10-29  0:00 ` Don Harrison
1996-10-29  0:00   ` Fergus Henderson
1996-10-30  0:00     ` Don Harrison
1996-10-30  0:00       ` Fergus Henderson
1996-10-31  0:00     ` David L. Shang
1996-11-01  0:00       ` Matt Kennel
1996-11-04  0:00         ` David L. Shang
1996-11-05  0:00           ` Matt Kennel
1996-11-06  0:00             ` David L. Shang
1996-11-04  0:00       ` Robert I. Eachus
1996-11-01  0:00     ` Jon S Anthony
1996-11-02  0:00       ` Fergus Henderson
1996-11-04  0:00       ` David L. Shang
1996-11-05  0:00         ` Jon S Anthony
1996-11-02  0:00     ` Darko BUDOR
1996-11-02  0:00       ` Fergus Henderson
1996-11-03  0:00         ` Darko BUDOR
1996-11-03  0:00         ` Matt Kennel
1996-11-03  0:00     ` Jon S Anthony
1996-11-03  0:00     ` Matthias Ernst
1996-11-05  0:00     ` Jon S Anthony
1996-11-10  0:00     ` Marcos F. F. de Macedo
1996-11-11  0:00       ` David L. Shang
1996-11-12  0:00         ` Fergus Henderson
1996-11-12  0:00           ` David L. Shang
1996-11-12  0:00             ` David L. Shang
1996-11-16  0:00             ` Fergus Henderson
1996-11-18  0:00               ` David L. Shang
1996-11-18  0:00             ` Kai Quale
1996-11-18  0:00               ` David L. Shang
1996-11-25  0:00                 ` Kai Quale
1996-11-15  0:00         ` Paul Johnson
1996-11-12  0:00       ` Alexander Asteroth
1996-11-11  0:00         ` Marcos F. F. de Macedo
1996-11-12  0:00         ` Matt Kennel
1996-11-12  0:00         ` Benedict A. Gomes
1996-10-29  0:00   ` Eiffel and Java + Ada dispatching Vincent WEBER
1996-10-30  0:00     ` Jean-Marc Jezequel
1996-11-01  0:00       ` Joachim Durchholz
1996-11-01  0:00       ` Don Harrison
1996-10-30  0:00     ` Don Harrison
1996-10-30  0:00       ` Jon S Anthony
1996-10-30  0:00   ` Robert I. Eachus
1996-10-30  0:00   ` Jon S Anthony
1996-11-04  0:00     ` Don Harrison
1996-11-04  0:00       ` C to Ada Ali Mirhosseini
1996-11-04  0:00         ` Matthew Daniel
1996-11-04  0:00         ` Robert Dewar
1996-11-05  0:00       ` Eiffel and Java + Ada dispatching Jon S Anthony
1996-11-05  0:00         ` Don Harrison
1996-11-06  0:00           ` Jon S Anthony
1996-10-30  0:00   ` Eiffel and Java David Petrie Stoutamire
1996-10-31  0:00   ` Eiffel and Java + Ada dispatching Jon S Anthony
1996-11-01  0:00     ` Jean-Marc Jezequel
     [not found]     ` <E06F2B.Az7@syd.csa.com.au>
1996-11-01  0:00       ` Jon S Anthony
1996-11-04  0:00         ` Don Harrison
1996-11-05  0:00           ` Jon S Anthony
1996-11-02  0:00       ` Robert Dewar
1996-11-04  0:00         ` Norman H. Cohen
1996-11-05  0:00         ` Don Harrison
1996-11-05  0:00           ` Robb Nebbe
1996-11-06  0:00             ` To overload or not to overload (was Eiffel and Java + Ada dispatching) Don Harrison
1996-11-06  0:00               ` Robb Nebbe
1996-11-07  0:00                 ` Don Harrison
1996-11-07  0:00                   ` Jon S Anthony
1996-11-07  0:00                   ` Juergen Schlegelmilch
1996-11-08  0:00                     ` Don Harrison
1996-11-08  0:00                       ` Don Harrison
1996-11-14  0:00                         ` Jon S Anthony
1996-11-14  0:00                     ` Jon S Anthony
1996-11-07  0:00                   ` Jon S Anthony
1996-11-11  0:00                     ` Don Harrison
1996-11-08  0:00                   ` bill.williams
1996-11-11  0:00                     ` Don Harrison
1996-11-07  0:00                 ` Norman H. Cohen
1996-11-06  0:00             ` Eiffel and Java + Ada dispatching Jean-Marc Jezequel
1996-11-07  0:00               ` Robb Nebbe
1996-11-08  0:00             ` Robert I. Eachus
1996-11-05  0:00           ` Joachim Durchholz
1996-11-06  0:00           ` Robert I. Eachus
1996-11-08  0:00             ` Don Harrison
1996-11-08  0:00               ` Jon S Anthony
1996-11-08  0:00               ` Robert A Duff
1996-11-12  0:00                 ` Don Harrison
1996-11-12  0:00                   ` Joachim Durchholz
1996-11-15  0:00                     ` Richard Riehle
1996-11-16  0:00                     ` Interfacing contracts (Was: Eiffel and Java + Ada dispatching) Geert Bosch
1996-11-17  0:00                       ` Robert A Duff
1996-11-12  0:00                   ` Eiffel and Java + Ada dispatching Robert A Duff
1996-11-13  0:00                     ` Don Harrison
1996-11-13  0:00                       ` Robert A Duff
1996-11-14  0:00                         ` Don Harrison
1996-11-13  0:00                       ` Jon S Anthony
1996-11-15  0:00                         ` Don Harrison
1996-11-19  0:00                           ` Jon S Anthony
1996-11-20  0:00                             ` Don Harrison
1996-11-14  0:00               ` Robert I. Eachus
1996-11-14  0:00                 ` Robert A Duff
1996-11-15  0:00                 ` Don Harrison
1996-11-15  0:00                   ` Robert I. Eachus [this message]
1996-11-19  0:00                     ` Don Harrison
1996-11-18  0:00                       ` Vincent Celier
1996-11-22  0:00                         ` Don Harrison
1996-11-19  0:00                 ` Jon S Anthony
1996-11-15  0:00               ` portmanteau (was Re: Eiffel and Java + Ada dispatching) Robert I. Eachus
1996-11-07  0:00           ` Eiffel and Java + Ada dispatching Jon S Anthony
1996-11-07  0:00           ` Robb Nebbe
1996-11-12  0:00           ` Jon S Anthony
1996-10-31  0:00   ` Joachim Durchholz
1996-11-01  0:00   ` Eiffel and Java Matthias Ernst
1996-11-01  0:00     ` Benedict A. Gomes
1996-11-01  0:00     ` William Clodius
1996-11-02  0:00   ` Eiffel and Java + Ada dispatching Jon S Anthony
1996-11-02  0:00   ` Jon S Anthony
1996-11-04  0:00   ` Eiffel and Java Robert I. Eachus
1996-10-30  0:00 ` Jon S Anthony
1996-11-01  0:00   ` Don Harrison
1996-11-01  0:00     ` Jon S Anthony
1996-11-07  0:00       ` Marcos F. F. de Macedo
1996-11-11  0:00         ` Ian Joyner
1996-11-12  0:00         ` Don Harrison
1996-11-13  0:00           ` Norman H. Cohen
1996-11-15  0:00             ` Don Harrison
1996-11-14  0:00           ` Jon S Anthony
1996-11-15  0:00             ` Don Harrison
1996-11-19  0:00               ` Jon S Anthony
1996-11-21  0:00                 ` Don Harrison
1996-11-12  0:00     ` Jon S Anthony
1996-10-31  0:00 ` Joachim Durchholz
1996-11-01  0:00 ` Jon S Anthony
1996-11-02  0:00 ` Jon S Anthony
1996-11-03  0:00 ` Eiffel and Java + Ada dispatching Joachim Durchholz
1996-11-04  0:00 ` Eiffel and Java Richard A. O'Keefe
replies disabled

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