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 X-Google-Thread: 103376,ff63dd9ded39893d X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Array Syntax Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Fri, 29 Feb 2008 18:48:03 +0100 Message-ID: <1o27nkm125mme.1953k42k1r4aa$.dlg@40tude.net> NNTP-Posting-Date: 29 Feb 2008 18:48:02 CET NNTP-Posting-Host: 5a7ee93b.newsspool4.arcor-online.net X-Trace: DXC=`JZI;TYN9BTYQ5E:lKKUS^X3WmamFLQ X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:20153 Date: 2008-02-29T18:48:02+01:00 List-Id: On Fri, 29 Feb 2008 07:19:06 -0800 (PST), ma740988@gmail.com wrote: > Trying to garner a feel for Ada - while perusing texts - and I'm > having slight difficulties understanding array syntax. > > Max_Num : constant := 6; > > type Pixel_Data is > record > Num_Of_Values : Int32; > Is_Valid_Data : Boolean; > end record; > > type Pixel_Number is Int16 range 1 .. Max_Num ; > type Pixel_Data_Array is array > ( Pixel_Number range 1 .. Max_Num ) > of Pixel_Data; > > Pixel_Data_Array is an array 6 deep of composite type Pixel Data. So > far so good? > > Now given: > > Frames_In_Buffer : constant := 35 ; > Buffer_Pixel_Data : > array ( Int32 range 1 .. Frames_In_Buffer ) > of aliased Pixel_Data_Array ; > > From the looks of this Buffer_Pixel_data is an array within an array. Buffer_Pixel_Data is an anonymous array of arrays. > On paper I'm having a hard time representing this in part becuase I'm > having a hard time understanding how a multi-dimensional array can > have two separate types. It is a single-dimensional array which elements are single-dimensional arrays. When you index it you get a Pixel_Data_Array. When you index that once more, you get Pixel_Data. A two-dimensional array would be: type Pixel_Number is range 1..Max_Num; type Frame_Number is range 1..Frames_In_Buffer; type Image is array (Frame_Number, Pixel_Number) of Pixel_Data; That is indexed by one index, which is a tuple of Frame_Number and Pixel_Number. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de