From: "Adam Beneschan" <adam@irvine.com>
Subject: Statically matching constraints
Date: 2 Feb 2007 16:26:19 -0800
Date: 2007-02-02T16:26:19-08:00 [thread overview]
Message-ID: <1170462379.446684.247730@q2g2000cwa.googlegroups.com> (raw)
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
next reply other threads:[~2007-02-03 0:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-03 0:26 Adam Beneschan [this message]
2007-02-03 14:41 ` Statically matching constraints Ludovic Brenta
2007-02-06 1:13 ` Randy Brukardt
2007-02-06 2:27 ` Adam Beneschan
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox