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,7f854d193f44af15 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.wirehub.nl!transit.news.xs4all.nl!195.241.76.212.MISMATCH!tiscali!transit1.news.tiscali.nl!dreader2.news.tiscali.nl!not-for-mail Newsgroups: comp.lang.ada Subject: Re: access private element of base-class References: <2035878.fXVvL0czMB@linux1.krischik.com> From: Ludovic Brenta User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) Date: Sat, 02 Oct 2004 13:32:07 +0200 Message-ID: <87mzz5s6dk.fsf@insalien.org> Cancel-Lock: sha1:4jUoy5DgkTzRjRwATby2qv4GGHU= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: Tiscali bv NNTP-Posting-Date: 02 Oct 2004 13:35:27 CEST NNTP-Posting-Host: 83.134.239.182 X-Trace: 1096716927 dreader2.news.tiscali.nl 44105 83.134.239.182:37461 X-Complaints-To: abuse@tiscali.nl Xref: g2news1.google.com comp.lang.ada:4556 Date: 2004-10-02T13:35:27+02:00 List-Id: Brian May writes: >>>>>> "Rick" == Rick Santa-Cruz writes: > > >>> In C++ talk: Protection in Ada work on the "namespace" and not > >>> on the "class". This needs some getting use to but has the > >>> advantage that it works with classic (non OO) programming as > >>> well. > >> It also eliminates the need for "friends", an ugly kludge. > > Rick> Why this? > > In Ada you can put multiple "classes" in one package. Hence there is > no need to use "friends". > > This isn't as flexible at C++ friends, where you can make any class a > friend, but I have also heard complaints that C++ friends are too > flexible, making code complicated. You can also place things in child packages; these things can see the private part of the parent package's spec. By declaring a subprogram in the private part of the spec, you get the effect of the C++ "protected", not only for child classes but for everything declared in child packages. "Things" may be types and subprograms. For example: package P is type T is tagged private; procedure Foo (This : in T); private type T is tagged record Member : Integer; end record; function Protected (This : in T) return Integer; end P; package P.Q is procedure Friend_Proc (That : in out T); end P.Q; package body P.Q is procedure Friend_Proc (That : in out T) is begin P.Foo (That); That.Member := P.Protected (That); end Friend_Proc; end P.Q; -- Ludovic Brenta.