comp.lang.ada
 help / color / mirror / Atom feed
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 21:41:03 +0100
Date: 2018-01-21T21:41:03+01:00	[thread overview]
Message-ID: <p42tst$17l0$1@gioia.aioe.org> (raw)
In-Reply-To: e259c533-e930-48b5-8af4-1525e6b1abd1@googlegroups.com

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

  reply	other threads:[~2018-01-21 20:41 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
2018-01-21 20:15       ` Mehdi Saada
2018-01-21 20:41         ` Dmitry A. Kazakov [this message]
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