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,ASCII-7-bit X-Google-Thread: 103376,fba93c19bb4e7dbd X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-21 06:17:48 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: Q: Endless loop by dispatching Date: Mon, 21 Jul 2003 15:21:49 +0200 Message-ID: References: <3F188FDA.3000202@attbi.com> <3F18DB9D.5020205@attbi.com> <818nhv0hrmlheu622t82574blao7bqr0tt@4ax.com> <3F1BBB9B.2070800@attbi.com> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1058793465 15227259 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:40553 Date: 2003-07-21T15:21:49+02:00 List-Id: On Mon, 21 Jul 2003 10:08:45 GMT, "Robert I. Eachus" wrote: >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. Ah, and people are still claiming that multiple inheritance is a bad thing! Now look at this "single" inheritance. Actually, it is multiple! You declare, publicly, that X has Initialize, this is the interface No.1. Then in the private part you derive from Ada.Finalization.Controlled, but this is the interface No.2. Now you want to reconcile both having only single [interface] inheritance? It is a clear contradiction. Should we have solved MI, the above were for free. Another evil is that constructors/destructors are exposed as "normal" operations having some special semantincs attached to them *depending* on the context. This also won't work. The word "Initialize" suddenly becomes some very special for the compiler in the private part, being just a name in the public one. If it were just a procedure Foo, one could probably live with it. >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. IMO it should be illegal with any pragma: package A is type Public is tagged private; procedure Initialize(X: in out Public); private type Public is new Ada.Finalization.Controlled with... -- Error public and private views are incompatible! end A; It could be made legal only if primitive operation disallowing were supported: package A is type Public is tagged private; procedure Initialize(X: in out Public); private type Public is new Ada.Finalization.Controlled with... procedure Ada.Finalization.Controlled.Initialize (X: in out Public) is null; -- Down with it! -- Fine, now both views are compatible end A; A more interesting case: package AA is type Public is tagged private; private type Public is new Ada.Finalization.Controlled with... end AA; with AA; use AA; package B is type Public_Public is new Public with private; procedure Initialize(X: in out Public_Public); -- This is legal. B knows nothing about Public's origin -- so it cannot misuse it private type Public_Public is new Public with ... end B package AA.C is type Private_Public is new Public with private; procedure Initialize(X: in out Public_Public); -- This is an error. C knows Public's private, so -- its private part is illegal private type Private_Public is new Public with ... end AA.C > 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. --- Regards, Dmitry Kazakov www.dmitry-kazakov.de