comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.tsoh.plus-bug.bauhaus@maps.futureapps.de>
Subject: Pascal ranges  (was: Selective suppression of warnings --- gnat on GNU/Linux)
Date: Tue, 30 Dec 2008 15:11:17 +0100
Date: 2008-12-30T15:11:22+01:00	[thread overview]
Message-ID: <495a2c0a$0$30237$9b4e6d93@newsspool1.arcor-online.net> (raw)
In-Reply-To: <C57FBF1F.10631D%yaldnif.w@blueyonder.co.uk>

(see below) wrote:

>>>  The Pascal declaration:
>>>
>>>   type  somerange = 1..10;
>>>
>>> Means, in Ada:
>>>
>>>    SUBtype  somerange is Integer range 1..10;

> The point is that in Pascal they are NOT different types, so if one wants to
> mirror the semantics of the Pascal program - which is presumably the reason
> for translating it - one must do as I say.

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;

   type somestruct is
      record
         null;
      end record;

   function test(a : somerange) return integer;

end stage3;


for the Turbo Pascal input file

unit stage3;

interface

   type
      somerange = 1..10;
      somestruct = record  end;

   function test(a: somerange) : integer;

implementation
 ...
end.

Bits of history tell that programmers started protests when Modula/Wirth
introduced different, incompatible types such as INTEGER
and CARDINAL, together with type conversions and type cheats (pretty
much the same as instances of Unchecked_Conversion, I guess?)

Because, it seems, the protesters would have to type more characters
and state explicitly the conversions that they had previously just
thought about carefully and then delegated to the Depepartment of
The Obvious.


> 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:
If Pascal's integer ranges are not made for expressing
different types, then maybe Pascal programmers do their best
and carefully mix objects of logically distinct integer types
only when a conversion is logically valid. If a compiler can
help with this in case ranges are made different types by
default, why not?  (I.e., if a subtype constraint is enough
distinction, the type declarations would have to be turned
into subtype declarations by hand, after the automatic
translation has turned Pascal ranges into different Ada
types.)




  reply	other threads:[~2008-12-30 14:11 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       ` Georg Bauhaus [this message]
2008-12-30 20:19         ` Pascal ranges (was: Selective suppression of warnings --- gnat on GNU/Linux) (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)
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