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 X-Received: by 10.236.23.130 with SMTP id v2mr4346388yhv.10.1430987548802; Thu, 07 May 2015 01:32:28 -0700 (PDT) X-Received: by 10.140.33.100 with SMTP id i91mr37693qgi.41.1430987548751; Thu, 07 May 2015 01:32:28 -0700 (PDT) Path: border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!j5no5799786qga.1!news-out.google.com!t92ni189qga.1!nntp.google.com!j5no5799784qga.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 7 May 2015 01:32:28 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=193.251.73.50; posting-account=O3LyFwoAAACc1uh60ZcOUmAGdDmGsEcV NNTP-Posting-Host: 193.251.73.50 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <21182bbe-e085-446c-9d89-32c3c263094a@googlegroups.com> Subject: Re: Polymorphism From: slos Injection-Date: Thu, 07 May 2015 08:32:28 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.giganews.com comp.lang.ada:193054 Date: 2015-05-07T01:32:28-07:00 List-Id: Le jeudi 7 mai 2015 09:28:46 UTC+2, Simon Wright a =E9crit=A0: > slos writes: >=20 > > 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. >=20 > If you do that, the compiler says >=20 > 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)) >=20 > The reason for this is that derived types wouldn't know that they needed > to implement the abstract operations. >=20 > If you make the private subprogram concrete, >=20 > function Area (O : Instance) return Float > is (raise Program_Error with "Area not implemented"); >=20 > then Circle.Area isn't overriding (because Object.Area isn't visible). >=20 > 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. >=20 >=20 > 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"). Thank you for your answer Simon. I have found this suitable for my needs : > 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. But I thought about something like a private inner package or interface may= have existed. BR, St=E9phane