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 (was: Selective suppression of warnings --- gnat on GNU/Linux) Date: Tue, 30 Dec 2008 20:19:34 +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 W92G63OrwYtRDUQ0DkyLNgbIxSJiShiYAr91pfqY0t8kx8q1Xa Cancel-Lock: sha1:1bUCo62GPcwpdksFcNY+z9WgflM= User-Agent: Microsoft-Entourage/12.14.0.081024 Thread-Topic: Pascal ranges (was: Selective suppression of warnings --- gnat on GNU/Linux) Thread-Index: Aclqu+3udDU6mAJ8fEqXTRXCuKYguw== Xref: g2news2.google.com comp.lang.ada:4107 Date: 2008-12-30T20:19:34+00:00 List-Id: On 30/12/2008 14:11, in article 495a2c0a$0$30237$9b4e6d93@newsspool1.arcor-online.net, "Georg Bauhaus" 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 chez blueyonder.co.uk