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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Preventing private procedure visibility being made public through extension Date: Thu, 25 May 2017 14:39:59 -0500 Organization: JSA Research & Innovation Message-ID: References: <4a47e4cd-829c-4451-abf1-82cf60b67706@googlegroups.com> <9cdf04e6-123e-4bd9-b466-77aad00d61bb@googlegroups.com> NNTP-Posting-Host: rrsoftware.com X-Trace: franka.jacob-sparre.dk 1495741200 9914 24.196.82.226 (25 May 2017 19:40:00 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 25 May 2017 19:40:00 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:46864 Date: 2017-05-25T14:39:59-05:00 List-Id: Your probably having trouble with the appropriaate view of My_Type. The full type of My_Type has both versions of Create (of course), as it inherits from View_Type. If you try to extend somewhere where that full view is visible, then that extension too will get both Creates. (That includes in the body and in any child packages.) OTOH, an extension somewhere that only has visibility on the private type, you should only get one (visible) Create. (But the other one is still inherited, it just can't be called directly.) I could go into more detail if you need that; it would help to have a full compilable example in that case so I can see where everything is declared. Randy. "Jere" wrote in message news:e9d5050e-1046-4f8a-92e0-feded33f7a50@googlegroups.com... > On Monday, May 22, 2017 at 5:17:47 PM UTC-4, Randy Brukardt wrote: >> "Jere" wrote in message >> ... >> > Definitely. I am also worried about someone copying the access >> > value and holding onto it past the lifetime of the object. I try >> > to avoid Access types when I can. I wish there was someway to >> > actually pass a limited type as a function return that didn't >> > involve build in place that can initialize. I just want to be >> > able to return the limited object out temporarily to access it: >> >> That's what generalized references are for. See 4.1.5 in the RM. >> >> Randy. > > That's a good point. I did end up playing with this and getting > an example working. After going through Jeffrey's example, I > ended up scrapping the access types altogether, but I do need > to learn to leverage this more in cases where access types > are necessary. > > Side question: > > If I have a type (Gnoga'ish example): > > type View_Base_Type is new Element_Type with private; --taggeed > type View_Type is new View_Base_Type with private; > procedure Create > (View : in out View_Type; > Parent : in out Base_Type'Class; > ID : in String := ""); > > -- Excuse any typos, this is hand typed code > > And then I extend it: > > type My_Type is new View_Base_Type with private; > procedure Create > (Obj : in out My_Type; > Parent : in out Window_Type'Class; -- derived from Base_Type'Class > ID : in String := ""); > > private > > type My_Type is new View_Type with null record; > > Sometimes if I subtype or extend My_Type, I get the ambiguous > calls to Create issue due to the inherited Create function > from View_Type. > > Since the extension of View_Type was private (I publicly > extended View_Base_Type), should there still be an > ambiguity between the Create procedures? My new > one shouldn't be an override and since the extension > to View_Type is private, it shouldn't be callable > (I'm not in a child package, this would be just > some other unrelated package subtyping or extending > My_Type). I get that before my extension was public > so making the Create procedure private wasn't an > option, but I had hoped with the full view being > private it wouldn't cause the ambiguity. I realize > in code that could view the private section the issue > might still be there, but this wouldn't be a package > that can see the private section.