comp.lang.ada
 help / color / mirror / Atom feed
* Statically matching constraints
@ 2007-02-03  0:26 Adam Beneschan
  2007-02-03 14:41 ` Ludovic Brenta
  2007-02-06  1:13 ` Randy Brukardt
  0 siblings, 2 replies; 4+ messages in thread
From: Adam Beneschan @ 2007-02-03  0:26 UTC (permalink / 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




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-02-06  2:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-03  0:26 Statically matching constraints Adam Beneschan
2007-02-03 14:41 ` Ludovic Brenta
2007-02-06  1:13 ` Randy Brukardt
2007-02-06  2:27   ` Adam Beneschan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox