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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3467cec1612741de X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-20 02:04:55 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!193.251.151.101!opentransit.net!wanadoo.fr!freenix!enst!enst.fr!not-for-mail From: "David C. Hoos, Sr." Newsgroups: comp.lang.ada Subject: Re: Anonymous array clarification. Date: Mon, 20 Aug 2001 03:29:35 -0500 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 998298294 40086 137.194.161.2 (20 Aug 2001 09:04:54 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Mon, 20 Aug 2001 09:04:54 +0000 (UTC) To: Return-Path: X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.4 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:12113 Date: 2001-08-20T03:29:35-05:00 ----- Original Message ----- From: "McDoobie" Newsgroups: comp.lang.ada To: Sent: August 20, 2001 1:18 AM Subject: Anonymous array clarification. > In Ada one can declare anonymous arrays (an array without a type assigned > to it.) However what would such an array be used for, and are the bounds > on it's use the same as for any other type of array. > I'm not sure where you got the idea that "In Ada one can declare anonymous arrays (an array without a type assigned to it.)." Array objects can be declared without any name haven been given to the _array type_, but the type of the _array elements_ must be declared. For example, suppose you have declared some type named My_Type. Then, you would (not using anonymous types) declare an array type like this: type My_Array_Type is array (Integer range <>) of My_Type; Then, an object could be declared like this: My_Array : My_Array_Type (1 .. 100); Instead, using an anonymous array type, you could declare your array object like this: My_Array : array (1 .. 100) of My_Type; In this case the type of My_Array is an anonymous array type, but the elements are still of a specific type -- i.e., My_Type. > I guess what I'm asking is if I declare an array such as > > some_array : array(1..N); > The declaration you suggest is illegal. > Can I assign values such as '1' '2' '3' 'H' 'y' '-' 'foo' all to the same > array? And how would those values be stored in memory? As Hex data with > thier values revealed according to the context of the code block they're > in? How would I tell it to read the data stored in that block as Integers, > Chars, et...? > There are a number of ways to accomplish what you desire. Since you speak of "reading the data," it souns like you might want to be using an Ada.Streams.stream_Element array, and implementing a memory stream package. Then you can use the stream attribute of the type of which you wish to read the data to read the data from the block. I use thus technique a lot -- particularly in cases where the value of some dataum read from the stream determines the type of subsequent stream elements in the array. > As a side note, I'll be downloading the source code to GNAT so that I can > get a better understanding as to how this all works. > I don't think the source code of anycompiler will do you as much good as readsing a good Ada text regarding stream attributes, or even the AdaLanguage Reference Manual. > Any help would be appreciated. > > Thanks > > McDoobie > > chris@dont.spam.me > _______________________________________________ > comp.lang.ada mailing list > comp.lang.ada@ada.eu.org > http://ada.eu.org/mailman/listinfo/comp.lang.ada >