comp.lang.ada
 help / color / mirror / Atom feed
From: "(see below)" <yaldnif.w@blueyonder.co.uk>
Subject: Re: Pascal ranges
Date: Wed, 31 Dec 2008 00:32:29 +0000
Date: 2008-12-31T00:32:29+00:00	[thread overview]
Message-ID: <C5806E1D.10646C%yaldnif.w@blueyonder.co.uk> (raw)
In-Reply-To: wcceizp1a3e.fsf@shell01.TheWorld.com

On 31/12/2008 00:07, in article wcceizp1a3e.fsf@shell01.TheWorld.com,
"Robert A Duff" <bobduff@shell01.TheWorld.com> wrote:

> "(see below)" <yaldnif.w@blueyonder.co.uk> writes:
> 
>> On 30/12/2008 23:19, in article wccmyed1cae.fsf@shell01.TheWorld.com,
>> "Robert A Duff" <bobduff@shell01.TheWorld.com> 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
<surname><forename> chez blueyonder.co.uk





  reply	other threads:[~2008-12-31  0:32 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-30  3:13 Selective suppression of warnings --- gnat on GNU/Linux Michael Mounteney
2008-12-30  8:03 ` Ludovic Brenta
2008-12-30 22:49   ` Michael Mounteney
2008-12-30 23:26     ` Robert A Duff
2008-12-30 11:01 ` (see below)
2008-12-30 11:37   ` Georg Bauhaus
2008-12-30 12:05     ` (see below)
2008-12-30 14:11       ` Pascal ranges (was: Selective suppression of warnings --- gnat on GNU/Linux) Georg Bauhaus
2008-12-30 20:19         ` (see below)
2008-12-30 23:19           ` Pascal ranges Robert A Duff
2008-12-30 23:34             ` (see below)
2008-12-31  0:07               ` Robert A Duff
2008-12-31  0:32                 ` (see below) [this message]
2008-12-30 23:13 ` Selective suppression of warnings --- gnat on GNU/Linux Robert A Duff
2008-12-31  9:46   ` Jean-Pierre Rosen
2008-12-31 14:55     ` Robert A Duff
2008-12-31 16:13       ` Jean-Pierre Rosen
2008-12-31 20:01         ` Robert A Duff
2008-12-31 18:43     ` (see below)
2008-12-31 19:49       ` Robert A Duff
2008-12-31 20:24         ` Jeffrey R. Carter
2008-12-31 22:38           ` Robert A Duff
2008-12-31 19:46 ` Jerry
2008-12-31 22:39   ` Robert A Duff
2008-12-31 23:37   ` Michael Mounteney
2009-01-01  9:45   ` sjw
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox