comp.lang.ada
 help / color / mirror / Atom feed
From: "(see below)" <yaldnif.w@blueyonder.co.uk>
Subject: Re: Pascal ranges  (was: Selective suppression of warnings --- gnat on GNU/Linux)
Date: Tue, 30 Dec 2008 20:19:34 +0000
Date: 2008-12-30T20:19:34+00:00	[thread overview]
Message-ID: <C58032D6.1063E6%yaldnif.w@blueyonder.co.uk> (raw)
In-Reply-To: 495a2c0a$0$30237$9b4e6d93@newsspool1.arcor-online.net

On 30/12/2008 14:11, in article
495a2c0a$0$30237$9b4e6d93@newsspool1.arcor-online.net, "Georg Bauhaus"
<rm.tsoh.plus-bug.bauhaus@maps.futureapps.de> wrote:

> Maybe, then, type mapping from Pascal ranges to Ada ranges,
> selecting either types or subtypes,
> will be an interesting switch to add to P2Ada?  I now get
> 
> -- Translated by (New) P2Ada v. 15-Nov-2006
> -- ...
> -- formatted by iccfmt_nt.exe
> 
> package stage3 is
> 
>    type somerange is range 1..10;
> ...

Yup. I complained about that to Gautier years ago. 8-)
It seems that the technology he was using did not permit a correct
translation to be made (doing it properly needs too much look-ahead).
 
>> Even writing afresh in Ada, it is very unlikely indeed that one would want
>> EVERY subrange to be a separate type.
> 
> OK, but OTOH, is a program improved when by default
> different Pascal ranges are mapped to Ada ranges of distinct
> types?  I think, yes, in case one assumes Ada requires stating
> assumptions explicitly by default:

Often, yes, it is, but there are cases where one wants to model in Pascal a
similar kind of relationship as exists between Integer, Natural and
Positive, but for a more restricted range. The need for these closely
related subranges is rather smaller in Ada, e.g. thanks to array attributes
such as 'First and 'Last. The Ada equivalents would be subranges of a common
base type, and so inter-convertible as painlessly as in Pascal. If these
subranges were all to be modelled by distinct types, much explicit type
conversion, to no useful effect, would be needed.

> If Pascal's integer ranges are not made for expressing
> different types,  ...

Well they are made for expressing constraints and distinctions. It's just
that Pascal's type system is not strong enough to express the finer
distinctions available in Ada, so Pascal programmers must make do with what
they have been given. That forces them to use related subtypes more than an
Ada programmer would need to (assuming of course, that they don't just use
Integer for everything, as a former colleague of mine insisted on doing).

-- 
Bill Findlay
<surname><forename> chez blueyonder.co.uk




  reply	other threads:[~2008-12-30 20:19 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) [this message]
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)
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