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!news3.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "(see below)" Newsgroups: comp.lang.ada Subject: Re: Pascal ranges Date: Wed, 31 Dec 2008 00:32:29 +0000 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> Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Trace: individual.net 8UpHZ0gGIXMLQ0MR/h3bPQeBcifkVAuUFhOOri5p8GJlEcy1gi Cancel-Lock: sha1:TdGzoFvmGnFMI3co/esG/2zQOFQ= User-Agent: Microsoft-Entourage/12.14.0.081024 Thread-Topic: Pascal ranges Thread-Index: Aclq30LvrzMMPeQ9h0yhJ5dGfOoUPA== Xref: g2news2.google.com comp.lang.ada:4119 Date: 2008-12-31T00:32:29+00:00 List-Id: On 31/12/2008 00:07, in article wcceizp1a3e.fsf@shell01.TheWorld.com, "Robert A Duff" wrote: > "(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). Sure. I said the need was smaller, not non-existent. 8-) My important point was that converting all Pascal subranges to distinct types creates a need for pointless type conversions. These might do damage to the type-safety mindset that is at least comparable with making everything a subrange of Integer, as Pascal does. -- Bill Findlay chez blueyonder.co.uk