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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: array of string Date: Sat, 4 Oct 2014 10:32:32 +0200 Organization: cbb software GmbH Message-ID: <1upa6p7nx1ar6$.ykhb0o5h2qen.dlg@40tude.net> References: <3ffbdc6a-e767-4de1-922f-c9c1ec748f4d@googlegroups.com> <017bf59f-074b-470e-b959-88e0a484bf63@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: ZB2Fb2q1fa4xpMpNKFqV6Q.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:22080 Date: 2014-10-04T10:32:32+02:00 List-Id: On Fri, 3 Oct 2014 18:29:16 -0700 (PDT), Stribor40 wrote: > I tried this... > > type Array_Type is array (1 .. 6, 1 .. 3) of Character; > myArray : Array_Type; > > myArray(1,1..3) := "abc" > > my compiler was mad at me because of this.....few subscripts in array reference nD arrays don't have slices in Ada. A language design bug, but nD slices would require a lot of type and subtype mechanics which is just missing. Note that unlike to 1D slices the result of a nD slice may be of a different type as in your case. There is a geometric number of types and their subtypes involved. For 1D slices it is just another subtype of the same type. Another language design bug is that you could not define the assignment for this case either. Assignment is not an operation in Ada. But you could write a subprogram: procedure Set_Row (A : in out Array_Type; Row : Positive; Value : String) is begin if Value'Length /= A'Length (2) then raise Constraint_Error with "Subscript error"; end if; for I in Value'Range loop A (Row, I - Value'First + A'First (2)) := Value (I); end loop; end Set_Row; Then Set_Row (myArray, 1, "abc"); -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de