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!.POSTED!not-for-mail From: "Alejandro R. Mosteo" Newsgroups: comp.lang.ada Subject: Referring to the instance of a generic parent package Date: Wed, 23 Oct 2019 14:54:38 +0200 Organization: A noiseless patient Spider Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Wed, 23 Oct 2019 12:54:39 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="feaa1199a1425bfc9f411fa7b721e765"; logging-data="1530"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+EC7880I26or3E7Kr7EYvo" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 Cancel-Lock: sha1:ov/oHWSqIWYUaEqAwR7cz7TuJsU= Content-Language: en-US X-Mozilla-News-Host: news://news.eternal-september.org:119 Xref: reader01.eternal-september.org comp.lang.ada:57332 Date: 2019-10-23T14:54:38+02:00 List-Id: I have the following situation: generic package Parent is ... end Parent; generic with package P is new Parent (<>); package Sibling is ... end Sibling; generic package Parent.Child is package A_Sibling is new Sibling (Parent); -- Works in GNAT CE 2019 -- Error in FSF 7.4: -- "Expect package instance to instantiate formal" end Parent.Child Now, since CE is more recent, I guess that's the correct one. Still, this made me think about name resolution inside a generic child. My guess is that actual instances take precedence, since a non-instance one can be prefixed with standard: generic package Parent.Child Standard.Parent -- Refers to the non-instance Parent -- Refers to the parent instance end Parent.Child; My cursory searching to look for relevant rules has been unsuccessful, I guess because I'm not finding the proper keywords. Assuming the above assumption is correct, I would like to make the initial hierarchy work in the FSF version too. I can of course make Child a non-child of Parent and also receive Parent as a generic formal. The question is, would there be another way of referring to a child's parent instance from the child? I tried this: generic package Parent.Child is package Renamed_Parent renames Parent; -- Works in FSF, but I guess that's not using the instance because: package A_Sibling is new Sibling (Renamed_Parent); -- Error: "actual parameter must be instance of Parent" The whole issue is not critical; I'm just generally curious. I'm experimenting with heavily nested generic child hierarchies and finding lots of corner cases (and visibility bugs). Cheers, Álex.