Statically matching constraints
- From: "Adam Beneschan" <adam@xxxxxxxxxx>
- Date: 2 Feb 2007 16:26:19 -0800
I'm having a bit of trouble understanding the "both are nonstatic and
result from..." clause of 4.9.1(1.3/2). According to 7.3(13), if you
have a discriminant on the ancestor subtype of a private extension,
the full definition must impose a statically matching constraint,
which takes you to 4.9.1. With this in mind, which of these examples
is legal?
package Pak1 is
X : Integer := 3;
type T1 (A : Integer) is tagged null record;
type T2 is new T1(X) with private;
private
type T2 is new T1(X) with null record;
end Pak1;
package Pak2 is
X : constant Integer := Some_Other_Package.Some_Function(100);
type T1 (A : Integer) is tagged null record;
type T2 is new T1(X) with private;
private
type T2 is new T1(X) with null record;
end Pak2;
package Pak3 is
X : Integer := 3;
type Sub is Integer range 1..X;
type T1 (A : Integer) is tagged null record;
type T2 is new T1(Sub'Last) with private;
private
type T2 is new T1(Sub'Last) with null record;
end Pak3;
My reading is that Pak1 and Pak2 are illegal but Pak3 seems to be
legal. The constraints are all nonstatic (the fact that X is a
constant in Pak2 isn't enough to make it static), but it seems to me
that Pak3 is the only one where the constraint results from something
mentioned in 4.9.1(1.3/2), since it seems to result from "the same
evaluation of a range of a discrete_subtype_definition", while in Pak1
and Pak2 the constraints result from evaluations of a variable or
constant, respectively. But it's a little confusing to me because I'm
not clear on just what "result from" is supposed to mean, and the AARM
is no help.
Is my interpretation correct?
(And yes, I already know you can make this legal by eliminating the
discriminant from the private extension declaration. That isn't my
question.)
-- thanks, Adam
.
- Follow-Ups:
- Re: Statically matching constraints
- From: Randy Brukardt
- Re: Statically matching constraints
- From: Ludovic Brenta
- Re: Statically matching constraints
- Prev by Date: Re: in defense of GC (was Re: How come Ada isn't more popular?)
- Next by Date: Re: Wasteful internationalization
- Previous by thread: Self Booting "Hello World" Ada example code?
- Next by thread: Re: Statically matching constraints
- Index(es):
Relevant Pages
|