comp.lang.ada
 help / color / mirror / Atom feed
From: stt@dsd.camb.inmet.com (Tucker Taft)
Subject: Re: Overloading for T and T'Class
Date: Tue, 15 Nov 1994 02:35:49 GMT
Date: 1994-11-15T02:35:49+00:00	[thread overview]
Message-ID: <CzAF7q.29E@inmet.camb.inmet.com> (raw)
In-Reply-To: 3a6goo$j7s@starbase.neosoft.com

In article <3a6goo$j7s@starbase.neosoft.com>,
David Weller <dweller@Starbase.NeoSoft.COM> wrote:

>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:
>>
>>	package P is
>>	  type T is tagged ... ;
>>	  procedure Op (X : in out T);
>>	  procedure Op (X : in out T'Class);
>>	  ...
>>	end P;
>>
>
>My neophyte language-lawerly sense says "No", you can't do this.  ...

Bzzz!  We will repeat the entire question for the other team...

Seriously, though, this is a subtle one.  You can declare the
subprograms, but you will have trouble writing a call on either one that is
not ambiguous.  An earlier version of the 9X proposals made it illegal
to declare two subprograms that were indistinguishable from a call
point of view.  However, this rule added significantly to the complexity
of the conformance rules, without producing commensurate benefits (in
our estimation).

> ...
>I think GNAT (at the moment) permits this, further confusing the
>issue.
>
>Your example was similar to an issue discussed during a presentation
>I made on the first version of the Booch COmponents at Tri-Ada.  

The above is legal, though a call would generally be ambiguous.
Actually, the class-wide operation can be called, provided the actual
parameter is of some descendant of T other than T or T'Class itself.  
Furthermore, the primitive operation once inherited by some 
descendant (say T2) would be callable, presuming T2 is declared
in some other package.  Hence, it is conceivable that the 
above might have some use, presuming no one wanted to use either
one with T or T'Class, but rather with other descendants of T such
as, say, T2 or T2'Class.

-Tucker Taft stt@inmet.com



  parent reply	other threads:[~1994-11-15  2:35 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
1994-11-16 11:33   ` Robert I. Eachus
     [not found] ` <3a6goo$j7s@starbase.neosoft.com>
1994-11-15  2:35   ` Tucker Taft [this message]
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