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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,caabf5265fad78e5 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!d32g2000yqh.googlegroups.com!not-for-mail From: Martin Newsgroups: comp.lang.ada Subject: Re: unsigned type Date: Mon, 29 Jun 2009 16:02:47 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <59O1m.404661$4m1.69194@bgtnsc05-news.ops.worldnet.att.net> <19faf5c6-1cce-4958-a308-bac61b6ff0eb@r10g2000yqa.googlegroups.com> NNTP-Posting-Host: 81.151.68.27 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1246316567 12736 127.0.0.1 (29 Jun 2009 23:02:47 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 29 Jun 2009 23:02:47 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: d32g2000yqh.googlegroups.com; posting-host=81.151.68.27; posting-account=g4n69woAAACHKbpceNrvOhHWViIbdQ9G User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.11) Gecko/2009060214 Firefox/3.0.10, Ant.com Toolbar 1.3,gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:6742 Date: 2009-06-29T16:02:47-07:00 List-Id: On Jun 29, 8:26=A0pm, a...@anon.org (anon) wrote: > =A0 =A0 =A0 =A0 Using Range attribute indexes the entire String or Array = and sometime > an algorithm may need sub-sets. Like instead of spanning =A0an 1K array t= he > algorithm, needs on 9 cells. 'sometime' /=3D 'most cases'... ...'most cases' is almost certainly Object'Range. I don't have access to all the Ada source ever written, so I can't say that with 100% certainty but I do know what makes up 'most cases' in the code I write. > =A0 =A0 =A0 =A0 And the 1..10 example you use states that your index is a= ll Natural > what if you use the "type Color is ( Blue, Green, Red, ... ) ;". 1..10 wo= uld > cause a compiler error. Type is also important. Did you actually read what I wrote? The '1 .. 10' example was for when needed to iterate a 'certain number of times' - nothing involving abstract concepts like 'iterator for each colour'. If I wanted to do that then fine, use: for C in Colour_Type loop -- whatever end loop; _unless_ your iterating over an array indexed by Colour_Type in which case the preferred style is, for C in Array_Indexed_By_Colour'Range loop -- whatever end loop; > But the compiler will assign > a scalar values for any enumeration type. And standards suggest that the > scalar value for the enumeration type begins with zero. > > =A0 =A0 =A0 =A0 Without standards, computer do not work! See above - it was nothing about enumerations. > In <19faf5c6-1cce-4958-a308-bac61b6ff...@r10g2000yqa.googlegroups.com>, M= artin writes: > > >On Jun 29, 9:54=3DA0am, "Dmitry A. Kazakov" > >wrote: > >> On Mon, 29 Jun 2009 01:42:31 -0700 (PDT), Martin wrote: > >> > On Jun 29, 12:08=3DA0am, a...@anon.org (anon) wrote: > >> >> And as for Natural, well, that is the definition of a String's inde= x a=3D > >nd in most > >> >> cases you use Naturals in "for loop' statements. > > >> > Why would you do that? > > >> > If you iterating over an array object (e.g. a String), you should us= e > >> > 'Range, e.g. > > >> > =3DA0 =3DA0for I in My_Array'Range loop > >> > =3DA0 =3DA0 =3DA0 -- whatever > >> > =3DA0 =3DA0end loop; > > >> Exactly. However there are cases like copying element of one array int= o > >> another, when you have to specify the index type explicitly. I always > >> wished an attribute Index, which for arrays would yield the index subt= ype > >> of the array: > > >> =3DA0 =3DA0Index : A'Index; > > >> Another issue is shifted views of arrays. E.g. when you get two arrays= A > >> and B, you could bring them to a coherent index range. > > >True but that hardly fits the billing of "most cases" cited by > >'anon'... > > >Cheers > >-- Martin > >