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 21:41:03 +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:50041 Date: 2018-01-21T21:41:03+01:00 List-Id: On 2018-01-21 21:15, Mehdi Saada wrote: > Thanks Dmitry. I just stumpled against another exemple of your point 1, RM's paragraph 11.2.8: > An exception_name of a choice shall not denote an exception declared in a generic formal package. > > What ? Doesn't it make them almost useless, then ?! Consider the same exception visible under different names coming from the same package. The compiler could not decide that when compiling the exception handler. But you can use an exception from a generic instance still. It is a general problem with generics that something legal when compiling it might turn legal or illegal depending on actual formal parameters. In some cases Ada just ignores that, e.g. by treating things wrongly or in an unexpected way, in other cases it tries to prevent that. It is an uphill battle. There is no way to fix generics/templates/macros. > It doesn't accept things like P1_instance.exception_name either, > which I don't get at all. It > should, if that rule ever was a concern about names hiding and such, > your point 1 that is. How do I do to STILL use exceptions declared in > generic package, in a handler ? I won't rewrite the package just for > this. Each time I try, there's always more work than expected. The rule is too keep it as simple as possible. If there is any way to ditch generics, do it. Use interfaces and tagged types, mix-ins, class-wide access discriminants etc to achieve polymorphism. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de