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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,12a63150f4f961a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.204.141.4 with SMTP id k4mr513667bku.6.1336088077977; Thu, 03 May 2012 16:34:37 -0700 (PDT) MIME-Version: 1.0 Path: h15ni195737bkw.0!nntp.google.com!news1.google.com!goblin1!goblin.stu.neva.ru!news.tornevall.net!news.jacob-sparre.dk!munin.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: OOP in Ada: Alternatives for "protected" scope Date: Thu, 3 May 2012 18:34:29 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1336088075 25939 69.95.181.76 (3 May 2012 23:34:35 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 3 May 2012 23:34:35 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Date: 2012-05-03T18:34:29-05:00 List-Id: "Felix Krause" wrote in message news:jnut8r$aqb$1@online.de... ... > The function Calculate should only be used internally. I do not see a good > way to enforce this with Ada: I do not want to move it to P_A's private > part, because child classes of A should not be required to be located in > sub-packages of P_A. (It's also forbidden for an abstract function to > reside in the private part.) > > In languages like Java and C#, there is a "protected" scope to cope with > this situation. Now of course these languages, unlike Ada, are based on > OOP, so it is natural for them to provide class-based visibility scopes. > My question is, how would one implement this kind of visibility in Ada? You gave the answer above, and then said you didn't like it. Well, not everything is as we wish it would be! For the record, Claw used the technique of putting "private" (what you called "protected") operations in the private part extensively. Most the root types were declared in package Claw (no implementations there) and all of the child types were in child packages. It works pretty well, other than a gotcha that can happen when deriving from a sibling class (you can't override the private operation in that case). We (the ARG) tried to fix that for Ada 2012, but the interface mechanism created insurmountable problems (another reason I hate interfaces). Randy.