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=unavailable autolearn_force=no version=3.4.4 Path: border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!1.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Polymorphism Date: Thu, 07 May 2015 08:28:45 +0100 Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="1d9954c1724cfc8838c424c9c295bd19"; logging-data="7530"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19u/rB8PXbmeyrEqtcZcB69Bd06xeokrdI=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (darwin) Cancel-Lock: sha1:bcLoW9vpCMS28aFxIJCqk+eAakw= sha1:0+Ns7zU4mQP5iFfn0tmTgm/KYC0= Xref: number.nntp.giganews.com comp.lang.ada:193052 Date: 2015-05-07T08:28:45+01:00 List-Id: slos writes: > 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. If you do that, the compiler says slos.ada:24:13: this primitive operation is declared too late slos.ada:24:13: abstract subprograms must be visible (RM 3.9.3(10)) The reason for this is that derived types wouldn't know that they needed to implement the abstract operations. If you make the private subprogram concrete, function Area (O : Instance) return Float is (raise Program_Error with "Area not implemented"); then Circle.Area isn't overriding (because Object.Area isn't visible). If you make Circle a child of Object (package Object.Circle), all is OK. This is of curse rather restrictive; it depends on who you want to be able to derive from Object.Instance. The workround I adopted in a similar situation was to comment the subprograms that had to be visible with "private use only". I think now I would make the names obviously logically private (e.g. "Private_Area").