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.36.89.1 with SMTP id p1mr2055342itb.16.1490562402900; Sun, 26 Mar 2017 14:06:42 -0700 (PDT) X-Received: by 10.157.18.133 with SMTP id g5mr1528115otg.8.1490562402874; Sun, 26 Mar 2017 14:06:42 -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!y18no85131itc.0!news-out.google.com!i72ni3573itb.0!nntp.google.com!y18no85128itc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 26 Mar 2017 14:06:42 -0700 (PDT) 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 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <7f095a51-f906-47b6-ac21-a8e07dc46726@googlegroups.com> Subject: Package formal parameter visibility From: Jere Injection-Date: Sun, 26 Mar 2017 21:06:42 +0000 Content-Type: text/plain; charset=UTF-8 Xref: news.eternal-september.org comp.lang.ada:46473 Date: 2017-03-26T14:06:42-07:00 List-Id: I ran into something that interested me while dorking around with some Ada code. The error makes sense when I think about it, but I ran into what looks like an inconsistency on the surface. Consider the package: ################## generic type My_Type is limited private; with procedure Do_Something(Instance : in out My_Type); package Package_A is subtype My_Subtype is My_Type; end Package_A; ##################### It doesn't do much on its own and if I try to use it like so: ##################### with Package_A; procedure Main is procedure Do_Something(Instance : in out Integer) is begin Instance := 23; end Do_Something; package A is new Package_A(My_Type => Integer, Do_Something => Do_Something); Var : A.My_Subtype; begin A.Do_Something(Var); end Main; ###################### I get the error: "Do_Something" is not a visible entity of "A" Fair enough, I can't use formal parameters in a client directly. If I want to, I have to either use some rename clauses or wrapper procedures. Tben I noticed I could do it if another generic package used it in this manner: ################################### with Package_A; generic with package A is new Package_A(<>); package Package_B is procedure Do_Something; end Package_B; ################################### ################################### package body Package_B is procedure Do_Something is Var : A.My_Subtype; begin A.Do_Something(Var); -- Shouldn't I get the error here? end Do_Something; end Package_B; ################################### If I use A as a formal parameter into another package, I suddenly get visibility of A's formal parameters in that new package. But isn't package B kind of a client of A in this scenario or does another rule apply here? NOTE: I realize I might be using the word "client" inappropriately here. I don't know the right terminology, so I hope at least the intent of my question is clear enough. Using GNAT GPL 2016 for compilation if it makes a difference