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 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.68.191.225 with SMTP id hb1mr1418350pbc.5.1336218850174; Sat, 05 May 2012 04:54:10 -0700 (PDT) Path: pr3ni6690pbb.0!nntp.google.com!news2.google.com!volia.net!news2.volia.net!feed-A.news.volia.net!news.musoftware.de!wum.musoftware.de!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: OOP in Ada: Alternatives for "protected" scope Date: Sat, 5 May 2012 13:53:59 +0200 Organization: cbb software GmbH Message-ID: References: <1vn9nv4aqm9a3.1tqzc91idjlbs$.dlg@40tude.net> <17kcn9g4qeg7j.5xole2f4bwbj$.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: KA5xyyPKkGZLxk9XJsNqLQ.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-05-05T13:53:59+02:00 List-Id: On Sat, 5 May 2012 10:28:43 +0200, Felix Krause wrote: > Yes, but that's not what I wanted. Let's have a more specific example > using orthogonal inheritance: > > package P is > type A is tagged private; > -- ... > end P; > > generic > type Base is new A with private; > package P.Extend is > type Extended is new Base with private; > -- ... > end P.Extend; > > package P.Q is > type B is new A with private; > -- ... > end P.Q; > > package P.Q.R is > package B_Extend is new P.Extend (Base => B); > type C is new B_Extend.Extended with private; > end P.Q.R; > > (I actually have some code with this structure.) I cannot possibly > access the private part of P.Extend in P.Q.R - although I'm extending > the class defined there. Extending = use. Using does not give special rights on the content! (:-)) The idea is that you create derived types in a way independent on the implementation of the parent. If the provider of the parent hid some stuff in the private part, there must be a good reason why nobody should look after. BTW, things hidden in the bodies are inaccessible by any means. My attitude to "private" is to treat it as a compromise helping the compiler to know what it should know, rather than a design tool to give access to children. Ideally, the private part should contain only things which cannot be moved to the body due to language constraints. > I cannot layout the packages in a way that > lets me access both P.Extend's and P.Q's private part in P.Q.R. Are you constructing the dreadful Rhombus? (:-)) If a package need to see internals of two packages it must be a descendant of both. This makes it generic if one of them is. package P is type A is tagged private; -- ... end P; package P.Q is type B is new A with private; -- ... end P.Q; generic type Base is new A with private; package P.Q.Extend is type Extended is new Base with private; -- ... end P.Q.Extend; generic package P.Q.Extend.R is type C is new Extended with private; end P.Q.Extend.R; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de