From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,CP1252 X-Google-Thread: 103376,fba93c19bb4e7dbd X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-21 03:08:51 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!news.gtei.net!newsfeed.mathworks.com!wn13feed!wn12feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!sccrnsc01.POSTED!not-for-mail Message-ID: <3F1BBB9B.2070800@attbi.com> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Q: Endless loop by dispatching References: <3F188FDA.3000202@attbi.com> <3F18DB9D.5020205@attbi.com> <818nhv0hrmlheu622t82574blao7bqr0tt@4ax.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit NNTP-Posting-Host: 66.31.71.243 X-Complaints-To: abuse@comcast.net X-Trace: sccrnsc01 1058782125 66.31.71.243 (Mon, 21 Jul 2003 10:08:45 GMT) NNTP-Posting-Date: Mon, 21 Jul 2003 10:08:45 GMT Organization: Comcast Online Date: Mon, 21 Jul 2003 10:08:45 GMT Xref: archiver1.google.com comp.lang.ada:40541 Date: 2003-07-21T10:08:45+00:00 List-Id: 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.