From: "Randy Brukardt" <randy@rrsoftware.com>
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 19:23:48 -0600
Date: 2018-01-22T19:23:48-06:00 [thread overview]
Message-ID: <p462r4$439$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: p42tst$17l0$1@gioia.aioe.org
"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
news:p42tst$17l0$1@gioia.aioe.org...
...
> 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.
To put this statement into language-lawyer terms, Ada generally uses
"assume-the-best/assume-the-worst" when it comes to checking Legality Rules
that depend on actual parameters. In a generic specification, the rules are
checked "assume-the-best" and are rechecked when the generic is
instantiated. In a generic body, the rules are checked "assume-the-worst".
(Which means sometimes you can get rid of an error by moving a declaration
into the private part of the specification.)
For some rules, "assume-the-worst" would result in not allowing a feature at
all. In such cases, the rules are checked with a dynamic check instead
(typically, raising Program_Error if the code would have been illegal if not
in a generic body).
I'm not aware of any cases remaining where Ada just does the wrong thing,
but Dmitry is correct that this has been a never-ending battle that tends to
get repeated every time we invent a new feature.
And of course, that's just the language. Compilers tend to get these rules
wrong or simply forget to implement them, since they're uncommon. Which
compounds the annoyances. (ACATS Test submissions are always welcome,
especially in this area, presuming that there isn't already a test for the
issue.)
Randy.
next prev parent reply other threads:[~2018-01-23 1:23 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
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 [this message]
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