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!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: making a son benefit access ton an instanciation of a generic package required as a formal parameter to his father and instanciated by him Date: Sun, 21 Jan 2018 18:50:18 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <193126c2-f171-43ed-8c7c-00570f1dd4d4@googlegroups.com> <1eb1f57d-36fa-4bf0-8a40-5b32d71e5c28@googlegroups.com> NNTP-Posting-Host: f8WEMHpTPFsoaovNG/8BOQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.8.2 Xref: reader02.eternal-september.org comp.lang.ada:50039 Date: 2018-01-21T18:50:18+01:00 List-Id: On 2018-01-21 18:30, Mehdi Saada wrote: > Child package, right. > Sorry, seems like I mixed things up a bit. > My setup is below, but I think it's already done, and I misunderstood from mispelling the exception ("zero_division" instead of "zero_denominator". Stupid me. > > with P1_G; > generic > with package P1 is new P1_G(<>); > Max : Positive; > package P2 is [...] end P2. > package body P2_G is [...] end P2_G; > > generic > package P2_G.Child is [...] end P2_G.Child; -- child package > package body P2_G.Child > [...] -- I wanted exceptions declared in P1_G (or P1, I dont know the details here) to be visible here, but it OBVIOUSLY already the case. > end P2_G.Child. For visibility you always use "use", which is logical, isn't it? Now some remarks: 1. It is a bad idea to declare anything in a generic package which is not a subject parametrization. Exception is a simple value. It has nothing to seek in a generic. Especially because each instance of the generic will produce a new exception. Make a parent package instead: package My_Stuff is Baz : exception; -- One exception for all end My_Stuff; generic ... package My_Stuff.P1_G is ... 2. There are strange, if not outright stupid, rules about visibility of generic formal parameters in generic children. Strangeness of these rules is multiplied by compiler bugs infesting implementations of generics. Only a language lawyer call tell what is just an effect of these rules and what of the bugs. A pragmatical approach to resolve the mess without drowning there is to rename all stuff coming from the formals you would like to use later in children. E.g. generic with package P1_G is ... package P2 is Baz : exception renames P1_G.Baz; -- It won't get lost 3. Remember that Ada did visibility of renamings wrong. A renaming can hide the renamed object! So you must be careful if both original exception and its renaming become visible, you will see none. They hide each other. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de