comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Re: Statically matching constraints
Date: Sat, 03 Feb 2007 15:41:45 +0100
Date: 2007-02-03T15:41:45+01:00	[thread overview]
Message-ID: <87mz3vmhg6.fsf@ludovic-brenta.org> (raw)
In-Reply-To: 1170462379.446684.247730@q2g2000cwa.googlegroups.com

Adam Beneschan writes:
>   package Pak3 is
>        X : Integer := 3;
>        type Sub is Integer range 1..X;

Surely you meant

         subtype 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),

X would be static, I think, if Some_Function were a static function,
since you are already passing a static parameter to Some_Function.
That would make Pak2 legal.

> 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.)

How about

       type T1 (A : Integer) is tagged null record;
       type T2 is new T1(A : Integer) with private;
  private
       type T2 is new T1(A => X) with null record;

Would that be legal?

Sorry I can't be of more help, asking more questions instead of
answering :) but FWIW I agree with your interpretation of
4.9.1(1.3/2).

-- 
Ludovic Brenta.



  reply	other threads:[~2007-02-03 14:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-03  0:26 Statically matching constraints Adam Beneschan
2007-02-03 14:41 ` Ludovic Brenta [this message]
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