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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: Victor Porton Newsgroups: comp.lang.ada Subject: Bad influence of private part on what subprograms can be defined Date: Mon, 09 Oct 2017 01:52:03 +0300 Organization: Aioe.org NNTP Server Message-ID: NNTP-Posting-Host: 8U0x309/ia0QUzusgm/krA.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Complaints-To: abuse@aioe.org User-Agent: KNode/4.14.10 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:48400 Date: 2017-10-09T01:52:03+03:00 List-Id: The following does not compile: $ gnatmake -gnat2012 test gcc-7 -c -gnat2012 test.adb test.adb:18:20: subprogram "X" overrides inherited operation at line 21 gnatmake: "test.adb" compilation error -- test.adb procedure Test is package A is type A_Type is tagged null record; not overriding procedure X(Object: A_Type); end; package body A is procedure X(Object: A_Type) is begin null; end; end; package B is type B_Type is tagged private; not overriding procedure X(Object: B_Type); private -- type B_Type is tagged null record; type B_Type is new A.A_Type with null record; end; package body B is procedure X(Object: B_Type) is begin null; end; end; begin null; end; So private part badly influences what can and what can and what cannot be done in the public part. Private must be private! Also note that if we would not use "not overriding" then changing the ancestor in the private part would have the potential to influence semantics of the program! (not in the above code as both procedures X are null, but in principle) Can anything be done around this issue? One possible solution is to allow "not overriding" (and behave as if it is not overriding) in public part even if it is considered overridable accordingly the private part (but not public part). This would make some non-compilable programs compilable, bit would not change semantic of compilable programs. So this is viable. Really bad! -- Victor Porton - http://portonvictor.org