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.200.54.20 with SMTP id m20mr9208812qtb.0.1495398091548; Sun, 21 May 2017 13:21:31 -0700 (PDT) X-Received: by 10.157.35.104 with SMTP id k37mr417010otd.14.1495398091506; Sun, 21 May 2017 13:21:31 -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!l39no756386qtb.0!news-out.google.com!v18ni5076ita.0!nntp.google.com!67no1218042itx.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 21 May 2017 13:21:31 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.71.201.205; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 173.71.201.205 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Preventing private procedure visibility being made public through extension From: Jere Injection-Date: Sun, 21 May 2017 20:21:31 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:46841 Date: 2017-05-21T13:21:31-07:00 List-Id: On Sunday, May 21, 2017 at 2:14:23 PM UTC-4, Robert Eachus wrote: > 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=20 > started with one package and have never let go of that=20 > model. You have two very different access patterns in=20 > mind (not access in the Ada sense). So you need two=20 > packages to declare them. Is there any reason to allow=20 > your clients to do anything with Base_Param other than=20 > pass it to subroutines you provide? I think not. I=E2=80=99m=20 > also going to avoid games like the Taft amendment, =20 > Use it if you want to. Sorry, that was just an example. The actual use case has=20 them in separate packages, but the problem is the same: 1. I want my type to be usable in the 3rd party library,=20 so I need to extend a type from it or provide access to an internal parameter of one of its types. 2. I don't want to provide some of the library type's public procedures as they can mess up my derived type if called. Per Dmitry's suggestion, I can provide runtime safety, but I was looking for static safety. At the moment I am leaning using an encapsulating type that passes back an access to an internal component so I can still interface to the library. I just don't like using access types if I can avoid them. So something like: type My_Type is tagged limited private; function Get_Libaray_Component (Obj : in out My_Type) return not null access Library_Type; private type My_Type is new Other_Library_Type with record Base : aliased Library_Type; end record; Then I can call: Library.Some_Library_Function(My_Var.Get_Library_Component.all); But none of Other_Library_Type's procedures can be publicly=20 called on my extended type, breaking it. Note that the library I am interfacing with already exists and is not mine. I don't want to modify it or else any code I augment it with won't be usable to others without them modding their copies as well.