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: 103376,d679dd7e9c16805a X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad.newshosting.com!newshosting.com!newspeer.monmouth.com!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Pascal ranges Date: Tue, 30 Dec 2008 19:07:01 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <7a6baa71-80e8-4f3a-80b6-34935bda2fc0@r10g2000prf.googlegroups.com> <495a0802$0$32677$9b4e6d93@newsspool2.arcor-online.net> <495a2c0a$0$30237$9b4e6d93@newsspool1.arcor-online.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1230682026 16605 192.74.137.71 (31 Dec 2008 00:07:06 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 31 Dec 2008 00:07:06 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:plAaSQTW56+5Q5SjgCSbFcuOusE= Xref: g2news2.google.com comp.lang.ada:4118 Date: 2008-12-30T19:07:01-05:00 List-Id: "(see below)" writes: > On 30/12/2008 23:19, in article wccmyed1cae.fsf@shell01.TheWorld.com, > "Robert A Duff" wrote: > >>> .. The need for these closely >>> related subranges is rather smaller in Ada, e.g. thanks to array attributes >>> such as 'First and 'Last. >> >> I don't understand why you say "need...rather smaller" here. >> I often have two subtypes of the same type, one for counting >> how many there are (0..N), and one for indexing into an array >> of them (1..N). Like this: >> >> type Blah_Index is range 1..N; >> subtype Blah_Count is Blah_Index'Base range 0..Blah_Index'Last; > > Because we could write: > > type Blah_Count is range 0..N; > ... array(Blah_Count range 1..Blah_Count'Last) of ... Yes, we could write that, but more commonly, we might want to write: ... array(Blah_Count range 1..Blah_Count'Last range <>) of ... which is illegal, so we write: ... array(Blah_Index range <>) of ... Seems to me, in Ada, one often needs a name for both (the "count" and the "index"). And we need the index [sub]type anyway, so we can declare objects of it. Such as the record component that records the last-used component of that array (which is inside the record). - Bob