From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2507b6d982782e45 X-Google-Attributes: gid103376,public From: stt@houdini.camb.inmet.com (Tucker Taft) Subject: Re: [Q] Problem with Array Concatenation? Date: 1997/07/09 Message-ID: #1/1 X-Deja-AN: 255820858 Sender: news@inmet.camb.inmet.com (USENET news) X-Nntp-Posting-Host: houdini.camb.inmet.com References: <33c280c8.418253@news.demon.co.uk> Organization: Intermetrics, Inc. Newsgroups: comp.lang.ada Date: 1997-07-09T00:00:00+00:00 List-Id: John McCabe (john@assen.demon.co.uk) wrote: : I would appreciate confirmation on whether the following piece of code : is legal Ada 83, and what the effect should be (obviously I haven't : bothered with Text_IO for outputting results, but what should happen : when I compile this?). This is legal Ada 83, but will raise Constraint_Error at run-time, because the result of the concatenation (before "sliding" happens) has a high bound of 150, which is outside the index subtype (which goes only from 1 up to 100) -- see paragraph RM83 4.5.3(6). In Ada 95, it would do the "expected," and give you an array with the values (51,52, ...,100,1,2,..., 50). This is thanks to paragraph RM95 4.5.3(6), which specially handles the case when the array type was defined by a constrained_array_definition, and essentially "pre-slides" the result, so the result of the concatenation has the bounds 1..100 rather than 51..150. This is one of those little annoyances from Ada 83 which we "fixed" in Ada 95. (I quote "fixed" because there are probably still those who find the Ada 83 approach in some sense to have more "purity of essence" -- aka POE for those Dr. Strangelove fans.) : ----------- : procedure Test is : type Arr_Type is array (1 .. 100) of Integer; : Src_Array : Arr_Type; : Dst_Array : Arr_Type; : begin : for Index in 1 .. 100 loop : Src_Array (Index) := Index; : end loop; : Dst_Array := (others => 0); : Dst_Array := Src_Array (51 .. 100) & Src_Array (1 .. 50); : end Test; : ----------- : Thanking you in advance. : Best Regards : John McCabe -- -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Burlington, MA USA