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: Polymorphism Date: Thu, 7 May 2015 09:41:58 +0200 Organization: cbb software GmbH Message-ID: <5hbl45anxasb.1jn73i00zgy2i.dlg@40tude.net> References: Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: enOx0b+nfqkc2k+TNpOejg.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:25747 Date: 2015-05-07T09:41:58+02:00 List-Id: On Wed, 6 May 2015 16:05:28 -0700 (PDT), slos wrote: > Please consider the following simple case : > > package Object is [...] > end Circle; > > I'd like function Object.Area to stay private but the compiler doesn't see > it like that and complains if I try to move it in the private part. > > In other words, I'd like to not expose internals to clients of the package. > > Any hint to achieve that ? If you privately override anything for something that is publicly dynamically polymorphic [~tagged], then that is not any private because you can [and must] be able to call the overriding body. The Ada's types model is that Circle.Instance has the function Area anyway. It is either implemented per inheritance of the parent's type implementation (if exists) or by providing a new body per overriding. Thus moving overriding into private changes nothing. I don't know why it is not allowed. Moreover, it probably would make sense to move all declarations of overriding into private or even further into the package body because the fact of overriding is mere an implementation detail, since the primitive subroutine is there anyway no matter what. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de