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.129.174.67 with SMTP id g3mr7899705ywk.66.1495390462317; Sun, 21 May 2017 11:14:22 -0700 (PDT) X-Received: by 10.157.45.79 with SMTP id v73mr408693ota.20.1495390462274; Sun, 21 May 2017 11:14:22 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!t26no740596qtg.1!news-out.google.com!v18ni5002ita.0!nntp.google.com!67no1195986itx.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 21 May 2017 11:14:21 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2601:191:8303:2100:5985:2c17:9409:aa9c; posting-account=fdRd8woAAADTIlxCu9FgvDrUK4wPzvy3 NNTP-Posting-Host: 2601:191:8303:2100:5985:2c17:9409:aa9c References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Preventing private procedure visibility being made public through extension From: Robert Eachus Injection-Date: Sun, 21 May 2017 18:14:22 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:46838 Date: 2017-05-21T11:14:21-07:00 List-Id: On Saturday, May 20, 2017 at 1:33:27 PM UTC-4, Jere wrote: > I tried to whittle this down to a small example, so forgive=20 > the uselessness of the example itself. I'm extending a=20 > library with some of my own components and I want (if possible)=20 > to allow my components to interact with the other library=20 > components as seamlessly as possible. >=20 > Say a library provides a tagged type with the following procedure: >=20 > Base.ads > ************************************************* > package Base is > =20 > type Base_Param is tagged null record; > =20 > type Base_Type is tagged null record; > =20 > procedure Something > (Obj : in out Base_Type;=20 > Value : Base_Param'Class)=20 > is null; > =20 > end Base; >=20 > ************************************************* ... I think that the problem you are dealing with is the you started with one p= ackage and have never let go of that model. You have two very different ac= cess patterns in mind (not access in the Ada sense). So you need two packa= ges to declare them. Is there any reason to allow your clients to do anyth= ing with Base_Param other than pass it to subroutines you provide? I think= not. I=E2=80=99m also going to avoid games like the Taft amendment, Use = it if you want to. generic type Object is limited private; =20 package Params is begin type Param is limited private; private type Access_Object is access Object; type Param is record Prev, Next: Access_Object; end record; end Params; with Params; package Base is type Base_Type is tagged null record; type Base_Access is limited private; procedure Something (Obj : in out Base_Type;=20 Value : Base_Access); private type Base_Access is access Base_Type; package My_Params is new Params(Base_Type); end Base; =20 package body Base =E2=80=93- declare any necessary operations of Base_Access here that way = you only need=20 -- one body=20 procedure Something (Obj : in out Base_Type;=20 Value : Base_Access) is begin null; end Something; end Base; I=E2=80=99ve used a mindset of you are going to be maintaining lists, datab= ases or whatever of Base_Type, and would want Base_Type to be derived from = Controlled or Limited_Controlled. If you do need both Base_Type to be tagg= ed, fine. You will find that the two package model works fine if the class= es, as such, are disjoint. But in Ada I have found that two tagged types in= the same package eventually lead to madness. If you have M (say 3) flavor= s of one type, and N (say 4) of the other, now you have M times N (twelve_= sets of derived operations that can exist. Adding another derivation will= always break something. Having the types declared in separate packages al= lows you to stay sane while trying to maintain the rats nest. I=E2=80=99ve= done the M plus N style with window managers where a dozen deep in one dim= ension (window manager) and six in another (program logic) was version 1.0= ...