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: Mon, 22 Jan 2018 09:28:20 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <193126c2-f171-43ed-8c7c-00570f1dd4d4@googlegroups.com> <1eb1f57d-36fa-4bf0-8a40-5b32d71e5c28@googlegroups.com> <6378807a-d938-4fac-938b-d3a8616d7f25@googlegroups.com> <297e4450-9934-40b8-9b55-1b16b3e421e4@googlegroups.com> <531299d8-af8e-45b4-9531-61a3bff7b42c@googlegroups.com> NNTP-Posting-Host: MyFhHs417jM9AgzRpXn7yg.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 6.1; 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:50050 Date: 2018-01-22T09:28:20+01:00 List-Id: On 22/01/2018 00:07, Mehdi Saada wrote: > I think I already got the idea, and wrote things accordingly... Though a (generic) child of a generic package WILL access through prefixing with his parents'name, not the name of this instance. So in this case things are really declared in the generic package. But I've no problem with that here: > > An exception is declared in an package, P1, instance of P1_G, and the RM says I can't use it in a handler... why so ? No, it does not say so. As Jeffrey already explained, generic package is not a package. An exception declared in a generic package is not an exception until the package is instantiated. You cannot reference to that fake exception as a normal one. generic package P is E : exception; -- This is not an exception yet end P; package True_Thing is new P; True_Thing.E -- This is an exception proper Now consider this: declare package True_Thing_1 is new P; package True_Thing_2 is new P; begin ... exception when True_Thing_1.E => -- Catch one E ... when True_Thing_2.E => -- Catch another E ... end; The fake exception within P refers to the true exception values from both instances, from all possible instances, actually. There are situations when that *generic* reference is ambiguous or undefined. This is the reason for limitations like the one you encountered. > Renaming doesn't work either. Renaming cannot change anything here. > It's stupid, why doesn't it behave like a normal package ! Because generics are macro expansions, they are not Ada, they are meta-language on top of normal Ada ("object language" is the term). Ada designers did a very tough job making generics act as if they were of the object language but there are limits of possible. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de