comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@dsd.camb.inmet.com (Bob Duff)
Subject: Re: Overloading for T and T'Class
Date: Tue, 15 Nov 1994 02:22:18 GMT
Date: 1994-11-15T02:22:18+00:00	[thread overview]
Message-ID: <CzAEL6.1w0@inmet.camb.inmet.com> (raw)
In-Reply-To: Cz4H8G.MA@swlvx2.msd.ray.com

In article <Cz4H8G.MA@swlvx2.msd.ray.com>,
John Volan <jgv@swl.msd.ray.com> wrote:
>In Ada9X, is it legal to overload the same subprogram name for both
>some tagged type T and its class-wide type T'Class?  For example:

Yes, but not particularly useful.

>	package P is
>	  type T is tagged ... ;
>	  procedure Op (X : in out T);
>	  procedure Op (X : in out T'Class);
>	  ...
>	end P;

This is legal, but calls to Op will tend to be ambiguous.  For example,
if Y is of type T, then Op(Y) might mean either one of the Ops, and
would therefore be ambiguous (and therefore illegal).

We considered making the above declarations be homographs, and therefore
illegal in the above case, but that caused some subtle semantic problems
(I can't remember the details right now), so we decided to allow it.
It's not necessary to make every useless thing illegal.

Anyway, don't do it.  ;-)

- Bob
-- 
Bob Duff                                bobduff@inmet.com
Oak Tree Software, Inc.
Ada 9X Mapping/Revision Team (Intermetrics, Inc.)



  parent reply	other threads:[~1994-11-15  2:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-11-11 21:33 Overloading for T and T'Class John Volan
1994-11-14  2:07 ` David Weller
1994-11-15  5:01   ` Cyrille Comar
1994-11-15  2:22 ` Bob Duff [this message]
1994-11-16 11:33   ` Robert I. Eachus
     [not found] ` <3a6goo$j7s@starbase.neosoft.com>
1994-11-15  2:35   ` Tucker Taft
1994-11-15 11:39     ` David Weller
1994-11-16  4:32       ` Brad Balfour
1994-11-16 14:34         ` John Volan
1994-11-15 14:15     ` Norman H. Cohen
1994-11-16  1:22 ` John Volan
1994-11-16 11:59   ` David Weller
1994-11-19  4:54   ` Cyrille Comar
replies disabled

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