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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Ada design bug or GNAT bug? Date: Sat, 4 Jul 2015 14:14:08 +0200 Organization: cbb software GmbH Message-ID: <1myo335gjwyy3$.1bthq0cugahll.dlg@40tude.net> References: <4lrj5zz2u2z.u8x9cf7xzic6.dlg@40tude.net> <1oyc7ksu2lrwz.1h4pqchzcyfzt.dlg@40tude.net> <56pbwdnfce0k$.5et1apcv65k9.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: evoS9sCOdnHjo0GRLLMU1Q.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:26610 Date: 2015-07-04T14:14:08+02:00 List-Id: On Fri, 3 Jul 2015 22:11:18 -0500, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:56pbwdnfce0k$.5et1apcv65k9.dlg@40tude.net... >> On Fri, 3 Jul 2015 12:33:07 -0500, Randy Brukardt wrote: >> >>> "Dmitry A. Kazakov" wrote in message >> >>>> But even if you convert to the class-wide you don't get visibility of >>>> the >>>> operation. In the scenario: >>>> >>>> type T3 is new T1 with private; >>>> private >>>> type T3 is new T2 with null record; -- Legal! >>>> >>>> a public client could not convert a T3 object to T2'Class. Could it? >>> >>> No, but a private client can, and if you have a public type T4 derived >>> from >>> T3, it would not have the function operation. >>> >>> package P2 is >>> type T3 is new T1 with private; >>> procedure Do_It (X : inT3); >>> private >>> type T3 is new T2 with null record; -- Legal! >>> end P2; >>> >>> with P2; >>> package P3 is >>> type T4 is new P2.T3 with C : Character; end record; -- No defined F >>> here. >> >> This must be illegal. The compiler shall require (unless T4 is abstract): >> >> 1. That the private part of the package had a full view of P2.T3 >> >> 2. F overridden there. > > But of course that breaks privacy: T4 knows nothing about the full type of > T3 or any private operations it may have. There are a lot of other cases where you effectively unable to derive from a type. Since they are not counted privacy breach, this one shouldn't either. In my view the problem is not in T4 but in T3, like in all other cases when you would not be able to derive later. So my solution would be a mandatory declaration of the public view as final. E.g. package P2 is type T3 is new T1 with private; -- Illegal, no derived types possible private type T3 is new T2 with null record; end P2; package P2 is type T3 is new T1 with private with Childless => True; -- Legal, this is the last public descendant private type T3 is new T2 with null record; end P2; Now, T4 cannot claim knowing nothing. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de