comp.lang.ada
 help / color / mirror / Atom feed
From: donh@syd.csa.com.au (Don Harrison)
Subject: Re: To overload or not to overload (was Eiffel and Java + Ada dispatching)
Date: 1996/11/08
Date: 1996-11-08T00:00:00+00:00	[thread overview]
Message-ID: <E0J2vy.E6C@syd.csa.com.au> (raw)
In-Reply-To: slrn5836sh.rl.schlegel@pella.informatik.uni-rostock.de


I wrote:

:>However, in relation to Eiffel, I'm saying that it has no *need* of an 
:>overloading mechanism because it is redundant due to the availability of 
:>covariance. An operation which you might choose to implement in Ada by 
:>overloading an inherited one (because they do the same job), you would 
:>implement in Eiffel as an overriding operation because it belongs in the 
:>same inheritance hierarchy (according to Eiffel's scheme of things).

These comments are made in the context of the example Jon Anthony and I
discussed. The different schemes of Ada and Eiffel might be demonstrated 
by expanding the example Jon and I were discussing.

Assuming types A and B with heirs C and D repectively. Consider the following
operations:

Ada                                        Eiffel
---                                        ------

A's operations
op (a: A; b: B'Class)                (1)    In A: op (b: B)                  (4)

B's operations
op (c: C; d: D'Class)  -- overloaded (2)   In C: op (d: D)      -- overrided (5)
op (c: C; b: B'Class)  -- inherited  (3)   In C: new_op (b: B)  -- new       (6)

What we see is that Ada has taken the safe approach of diverting polymorphism
down the avariant path (3). The specialised op (2) becomes an overloaded 
operation and is no longer polymorphic wrt (1). Note that (3) is more general
than (2).

On the Eiffel side, polymorphism continues down the line of specialisation
(true covariance) so that (5) is polymorphic wrt (4). The more general (6)
is a new operation.

Now the contentious part. :(  The issue of which model is 'correct' depends on
which operation of B can better be regarded as functionally equivalent to 
the operation in A. (The safety issue is secondary, IMO - I'm talking about
modelling integrity). What seems to happen in the real world is that as
interactions between things become more specific, the things involved become
more specific as well (or some may stay the same). (The things do not become
*less* specific, but that is another matter). To model this faithfully,
you would need multiple dispatching but for most purposes, you can use use the
simpler (but lop-sided) model of single dispatching. But the important thing
is that we need to cater for the situation of both things becoming more
specific. If we don't, then what we end up with is specialisations that are
lop-sided and are capable of modelling only the special case where only one
thing becomes more specialised. (This is what happens in Ada).

I think the choice in Eiffel of making specialisations functionally equivalent
to their generalisations is the right one in terms of modelling integrity.
The downside is having then to deal with the non-trivial problem of breaking
polymorphism. :(  By comparison, the Ada model is completely safe, but it
sacrifices modelling integrity to acheive it, IMO.


Juergen Schlegelmilch wrote:

:Hm, being not too familiar with Ada, I may be wrong, but in the subclass
:you have both operations available, while with Eiffel's redefinition you
:only have the redefined but not the inherited (unless you inherited once,
                                                                     ^^^^
                                                                     twice?

:but then you have to rename). Thus, in a piece of code where an operation 
:is applied to arguments suitable only for the inherited version, Eiffel 
:will signal a type error (system validity or by runtime crash :-), 

IMO, this is what ought to happen because because the operation has become 
more specific and so requires more specific parameters. The parameter 
combination provided is invalid, so the runtime system (correctly) raises an 
exception. This highlights the fact that there is an error in the client which 
must be fixed. If a more general operation realy *is* required, then you can 
define a *new* operation [(6) in my example] for this purpose. So, Eiffel 
dispatches to a more specific operation by default rather than to a more general 
one. This differs from Ada which ...

: will use the inherited (overloaded) version.

So, Ada dispatches to a more general operation by default rather than to a 
more specific one. This is the wrong way round, IMO. I think calling a more 
general operation ought to be the exception rather than the default. Some will 
not agree with me but that's okay. :)

:So, covariant redefinition is not a mechanism to implement/simulate 
:overloading.

Just as well I didn't say that then. :)

I *am* saying that because Eiffel is covariant, you don't have to re-invent
an operation as an overloaded operation due to inheriting some unwanted 
baggage that no longer reflects the specialisation of an abstraction. 


Don.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Don Harrison             donh@syd.csa.com.au






  reply	other threads:[~1996-11-08  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   ` Alexandre Oliva
1996-10-28  0:00   ` David Hanley
1996-10-28  0:00     ` Matt Kennel
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   ` 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-29  0:00   ` Eiffel and Java 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         ` Matt Kennel
1996-11-03  0:00         ` Darko BUDOR
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         ` Benedict A. Gomes
1996-11-12  0:00         ` Matt Kennel
1996-10-30  0:00   ` David Petrie Stoutamire
1996-10-30  0:00   ` Eiffel and Java + Ada dispatching 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   ` Robert I. Eachus
1996-10-31  0:00   ` Joachim Durchholz
1996-10-31  0:00   ` Jon S Anthony
     [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           ` Joachim Durchholz
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                 ` Norman H. Cohen
1996-11-07  0:00                 ` Don Harrison
1996-11-07  0:00                   ` Juergen Schlegelmilch
1996-11-08  0:00                     ` Don Harrison [this message]
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-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-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-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                   ` 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-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-14  0:00               ` Eiffel and Java + Ada dispatching 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
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 Robb Nebbe
1996-11-07  0:00           ` Jon S Anthony
1996-11-12  0:00           ` Jon S Anthony
1996-11-01  0:00     ` Jean-Marc Jezequel
1996-11-01  0:00   ` Eiffel and Java Matthias Ernst
1996-11-01  0:00     ` William Clodius
1996-11-01  0:00     ` Benedict A. Gomes
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