[comp.lang.ada] 'Base and Staticness

arny@wayback.UUCP (04/13/87)

In article <12293281394.11.MENDAL@Sierra.Stanford.EDU>, Mendal@SIERRA.STANFORD.EDU (Geoff Mendal) writes:
> Is the following package specification semantically valid?
> 
>   package Static_Test is
>     subtype Non_Static is Integer range Integer (1) .. 100;
> 
>     type Must_Be_Static is range Non_Static'Base'First .. 10;
>   end Static_Test;
> 
> Read the ARM, 3.3.3(8..9) and 4.9(1..2, 8, 11).


   Forgive me if I missed something, but after checking the LRM sections you
mentioned above (especially 4.9:11), I believe the subtype "Non_Static" is
indeed static.  This subtype is formed by imposing a static range constraint
(1..100) on a scalar base type (Integer).  (Note that enclosing the numeral 1
in parentheses does not make it non-static according to 4.9:2,4,10).
   It follows that the declaration of "Must_Be_Static" is then valid according
to 4.9:8.

   Comments?

Arny B. Engelson   {ihnp4|bonnie|clyde}!wayback!arny   (201) 386-4816
AT&T Bell Laboratories, Whippany, N.J.

deller@vrdxhq.UUCP (04/14/87)

In article <1132@wayback.UUCP>, arny@wayback.UUCP (Arny B. Engelson) writes:

> > Is the following package specification semantically valid?
> >   package Static_Test is
> >     subtype Non_Static is Integer range Integer (1) .. 100;
> >     type Must_Be_Static is range Non_Static'Base'First .. 10;
> >   end Static_Test;
> > Read the ARM, 3.3.3(8..9) and 4.9(1..2, 8, 11).
> 
> ... I believe the subtype "Non_Static" is
> indeed static.  This subtype is formed by imposing a static range constraint
> (1..100) on a scalar base type (Integer).  (Note that enclosing the numeral 1
> in parentheses does not make it non-static according to 4.9:2,4,10).
> . . .

I believe you missed the fact that instead of "1", the expression is 
"Integer (1)", not simply "(1)".  "Integer (1)" is a type conversion, which is 
not listed in RM 4.9 as a static primary.  Using a "non-modifying" type
conversion is one of the typical "tricks" used to make expressions non-static.

Note that "Integer'(1)" is a qualified expression, which _is_ a static 
expression primitive, and is more likely to be used when "casting" (What, how
did C sneak in here?) a literal to a specific type.

Steven Deller,
Verdix
-- 
<end_message> ::= <disclaimer> | <joke> | <witty_saying> | <cute_graphic>
{verdix,seismo,umcp-cs}!vrdxhq!deller