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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news4.google.com!proxad.net!feeder1-2.proxad.net!news.wiretrip.org!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!feeder.news-service.com!feeder4.cambrium.nl!feed.tweaknews.nl!news.netcologne.de!newsfeed-hp2.netcologne.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Tue, 30 Dec 2008 15:11:17 +0100 From: Georg Bauhaus Reply-To: rm.tsoh+bauhaus@maps.futureapps.de User-Agent: Thunderbird 2.0.0.18 (Windows/20081105) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Pascal ranges (was: Selective suppression of warnings --- gnat on GNU/Linux) References: <7a6baa71-80e8-4f3a-80b6-34935bda2fc0@r10g2000prf.googlegroups.com> <495a0802$0$32677$9b4e6d93@newsspool2.arcor-online.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <495a2c0a$0$30237$9b4e6d93@newsspool1.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 30 Dec 2008 15:11:22 CET NNTP-Posting-Host: 9b32f263.newsspool1.arcor-online.net X-Trace: DXC=aPNfZePH74WYQ5E:l (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.)