comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam@spam.com>
Subject: Re: strings and multidimensional arrays
Date: Tue, 14 Oct 2003 01:10:42 GMT
Date: 2003-10-14T01:10:42+00:00	[thread overview]
Message-ID: <m2Iib.110$7a4.105@newsread4.news.pas.earthlink.net> (raw)
In-Reply-To: <3F8ADB3D.5010000@comcast.net>

Robert I. Eachus wrote:

> E:\Ada\Test>disc_test
> disc_test
>  TT(1,1) is ( D => ONE I => 1).
>  TT(2,2) is ( D => TWO C =>'2').
>  TT(3,3) is ( D => ONE I => 2013340188).
>  TT(4,4) is ( D => ONE I => 38010744).
>  TT(5,5) is ( D => FIVE I => 5.0).

This is about what I expected. We could provide default values for I, C, 
and F, and avoid the "stack junk" values for I in (3,3) and (4,4). Or 
assigned an initial value to TT.

> I'm not going to assert that this is wrong. That would be for the ARG as
> a whole to do.  The key paragraphs of the standard are 3.6(14): "An 
> array_type_definition defines an array type and its first subtype.
> For each object of this array type, the number of indices, the type and
> position of each index, and the subtype of the components are as in the
> type definition[; the values of the lower and upper bounds for each
> index belong to the corresponding index subtype of its type, except for
> null arrays (see 3.6.1)]."  This is the paragraph that implicitly sets 
> the discriminants for uninitialized components.

Is the subtype of

X : Discriminated_Record;

the same as of

Y : Discriminated_Record (D => One);

? The discriminant of X can change; of Y cannot.


> The first quote implies that the subtype of the components can't be 
> changed, the second implies they can be unless the components are 
> declared as aliased.  (Adding the wrapper type allows you to declare the 
> components aliased.)  I'll wait to see what Bob Duff, Randy, and 
> possibly Tucker have to say.  Certainly this is not documented as a 
> change from Ada 83 in the AARM.  But even if it wasn't intended as 
> legal, it is a nice feature. ;-)

That's a consequence of aliased I hadn't encountered, and the wrapper 
trick is a good thing to know. I didn't realize I was getting into an 
area that would require attention from the ARG. It seems like a 
significant incompatability from Ada 83 not to allow assignment to 
"normal" unconstrained record components.

-- 
Jeff Carter
"When danger reared its ugly head, he bravely
turned his tail and fled."
Monty Python and the Holy Grail
60




  parent reply	other threads:[~2003-10-14  1:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-12  4:05 strings and multidimensional arrays Andrew
2003-10-12  5:24 ` Andrew
2003-10-12  6:27   ` tmoran
2003-10-12 14:16   ` Robert I. Eachus
2003-10-12 19:34     ` Jeffrey Carter
2003-10-13  0:02       ` Robert I. Eachus
2003-10-13  3:14         ` Jeffrey Carter
2003-10-13 17:05           ` Robert I. Eachus
2003-10-13 18:49             ` Martin Dowie
2003-10-13 21:47               ` Mark Lorenzen
2003-10-14  1:10             ` Jeffrey Carter [this message]
2003-10-14 15:29               ` Robert I. Eachus
2003-10-12 21:01     ` Andrew
2003-10-13 13:59 ` Rodrigo Garcia
  -- strict thread matches above, loose matches on Subject: below --
2003-10-14  6:24 christoph.grein
replies disabled

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