From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
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
Date: 2018-01-21T18:50:18+01:00 [thread overview]
Message-ID: <p42jso$mjn$1@gioia.aioe.org> (raw)
In-Reply-To: 1eb1f57d-36fa-4bf0-8a40-5b32d71e5c28@googlegroups.com
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
next prev parent reply other threads:[~2018-01-21 17:50 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-21 15:43 making a son benefit access ton an instanciation of a generic package required as a formal parameter to his father and instanciated by him Mehdi Saada
2018-01-21 15:58 ` Simon Wright
2018-01-21 17:30 ` Mehdi Saada
2018-01-21 17:39 ` Simon Wright
2018-01-21 17:50 ` Dmitry A. Kazakov [this message]
2018-01-21 20:15 ` Mehdi Saada
2018-01-21 20:41 ` Dmitry A. Kazakov
2018-01-21 21:29 ` Mehdi Saada
2018-01-21 21:31 ` Mehdi Saada
2018-01-21 22:20 ` Jeffrey R. Carter
2018-01-21 23:07 ` Mehdi Saada
2018-01-21 23:10 ` Mehdi Saada
2018-01-22 8:28 ` Dmitry A. Kazakov
2018-01-22 9:25 ` Simon Wright
2018-01-23 1:23 ` Randy Brukardt
2018-01-21 22:04 ` J-P. Rosen
2018-01-22 15:36 ` Mehdi Saada
2018-01-22 15:54 ` Mehdi Saada
2018-01-22 15:52 ` Simon Wright
2018-01-23 1:33 ` Randy Brukardt
2018-01-23 14:05 ` Mehdi Saada
2018-01-23 1:13 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox