comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@attbi.com>
Subject: Re: Q: Endless loop by dispatching
Date: Mon, 21 Jul 2003 10:08:45 GMT
Date: 2003-07-21T10:08:45+00:00	[thread overview]
Message-ID: <3F1BBB9B.2070800@attbi.com> (raw)
In-Reply-To: 818nhv0hrmlheu622t82574blao7bqr0tt@4ax.com

Dmitry A. Kazakov wrote:

>>1) All objects of a type derived from Ada.Finalization.Controlled by 
>>default call the same version of Initialize? 
> 
> Which one version? How a public part might know that there is a
> privately declared Initialize?
> 
>>or
>>
>>2) Information hiding in effect AT THE PLACE OF THE CALL can determine 
>>which version of a subprogram is called?
> 
> For good or bad, but this was the intention, i.e. to hide Initialize
> and here you are.

Yep.

> I think that the syntax should clearly distinguish declaring a
> primitive (and thus overriding) vs. non-primitive (overloading)
> subprogram. Further, no matter how painful it could be, one should
> probably outlaw non-primitive subprograms with tagged non-class-wide
> arguments.

Actually the syntax is such that it is very difficult to have tagged 
types which are not publically tagged.  (I used to drive Tuck crazy, I 
think, during the Ada 9X process with examples using generic 
instantiations to get a type declared as "type Visible is private;" but 
which was actually a tagged type.  But let's leave those cases aside for 
a moment.  The real devilish problem occurs when the public type is tagged:

    type Public is tagged private;

    procedure Initialize(X: in out Public);

and the full declaration:

    type Public is new Ada.Finalization.Controlled with...

results in a subprogram becoming overriding in part of its scope.  That 
is what pushes for choice 1 above.  It is clear that currently 2 is 
intended by the RM, but if anyone finds themselves in this mess the 
likelihood that they will "get it right" is low.  (Remember, not even 
GNAT does.)  Also note that, in the above example, declaring Initialize 
(publicly) non-overriding is actively harmful.

I've suggested a "will override" choice for the pragma or keyword.  But 
as you say, that exposes what the programmer obviously knows is going to 
happen in the private part.  Note that there are cases where you have a 
child package containing a type derived from a private type in the 
parent package, and where you NEED for the "will override" operation to 
be public.  It is not an easy problem.

-- 

                                            Robert I. Eachus

�In an ally, considerations of house, clan, planet, race are 
insignificant beside two prime questions, which are: 1. Can he shoot? 2. 
Will he aim at your enemy?� -- from the Laiden novels by Sharon Lee and 
Steve Miller.




  reply	other threads:[~2003-07-21 10:08 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-11  8:22 Q: Endless loop by dispatching Michael Erdmann
2003-07-11  9:46 ` Jean-Pierre Rosen
2003-07-11 15:19   ` Michael Erdmann
2003-07-11 10:01 ` Q: " Dmitry A. Kazakov
2003-07-11 15:07   ` Michael Erdmann
2003-07-12  1:41     ` Jeffrey Carter
2003-07-14  8:48     ` Dmitry A. Kazakov
2003-07-14 18:38       ` Randy Brukardt
2003-07-15  8:47         ` Dmitry A. Kazakov
2003-07-15 17:23           ` Randy Brukardt
2003-07-16  8:08             ` Dmitry A. Kazakov
2003-07-16 17:44               ` Robert I. Eachus
2003-07-17  1:57               ` Robert A Duff
2003-07-18  9:10                 ` Dale Stanbrough
2003-07-18 20:26                   ` Robert I. Eachus
2003-07-18 21:35                     ` tmoran
2003-07-19  0:25                       ` Robert I. Eachus
2003-07-19  2:30                         ` tmoran
2003-07-19  5:48                           ` Robert I. Eachus
2003-07-21  8:38                             ` Dmitry A. Kazakov
2003-07-21 10:08                               ` Robert I. Eachus [this message]
2003-07-21 13:21                                 ` Dmitry A. Kazakov
2003-07-21 18:51                                   ` Robert I. Eachus
2003-07-22  7:41                                     ` Dmitry A. Kazakov
2003-07-22 10:36                                       ` Lutz Donnerhacke
2003-07-22 12:11                                         ` Dmitry A. Kazakov
2003-07-22 12:18                                           ` Lutz Donnerhacke
2003-07-22 14:46                                             ` Dmitry A. Kazakov
2003-07-22 15:11                                               ` Lutz Donnerhacke
2003-07-23  8:12                                                 ` Dmitry A. Kazakov
2003-07-19 14:44                     ` Chad R. Meiners
2003-07-20 12:36                       ` Robert I. Eachus
2003-07-11 16:27 ` T. Kurt Bond
2003-07-12  8:37   ` Michael Erdmann
2003-07-15  7:11     ` Kenneth Almquist
replies disabled

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