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.9 required=5.0 tests=BAYES_00,LOTS_OF_MONEY autolearn=ham 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 01:00:41 PST From: "Phil Thornley" Newsgroups: comp.lang.ada References: Subject: Re: Anonymous array clarification. Date: Mon, 20 Aug 2001 09:03:25 +0100 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 NNTP-Posting-Host: 172.31.7.65 Message-ID: <3b80c13f$1@pull.gecm.com> X-Trace: 20 Aug 2001 08:50:23 GMT, 172.31.7.65 Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!195.54.122.107!newsfeed1.bredband.com!bredband!diablo.netcom.net.uk!netcom.net.uk!btnet-peer!btnet-peer0!btnet-feed5!btnet!newreader.ukcore.bt.net!pull.gecm.com!172.31.7.65 Xref: archiver1.google.com comp.lang.ada:12111 Date: 2001-08-20T09:03:25+01:00 List-Id: "McDoobie" wrote in message news:tY1g7.45466$K6.17744072@news2... > 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 guess what I'm asking is if I declare an array such as > > some_array : array(1..N); > You have to give the component type as well: some_array : array(1..N) of Integer; -- or whatever so the question of how the components are stored doesn't arise. On the question of what they are used for, I most commonly use them for look-up tables. type Day is (Mon, Tue, Wed, Thu, Fri, Sat, Sun); Tomorrow : constant array (Day) of Day := (Tue, Wed, Thu, Fri, Sat, Sun, Mon); (which avoids a lot of stuff about 'Succ and worrying about wrap-around). You can't declare two anonymous arrays of the same type even in the same declaration: A, B : array (1 .. 5) of Integer; A and B are if different anonymous types and so can't be assigned (i.e. A := B; is an illegal statement). Note that an anonymous array can never be passed as the parameter of a subprogram as you can't name the parameter type. Cheers, Phil -- Phil Thornley Programmes, Engineering Warton