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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,583275b6950bf4e6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-22 14:14:10 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-06!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Quality systems (Was: Using Ada for device drivers? (Was: the Ada mandate, and why it collapsed and died)) Date: Thu, 22 May 2003 16:15:05 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: References: <3ec4b1c9$1@news.wineasy.se> <9fa75d42.0305161748.1735fc32@posting.google.com> <4W%xa.28765$cK5.11964@nwrdny02.gnilink.net> <1053353256.804734@master.nyc.kbcfp.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Newsreader: Microsoft Outlook Express 4.72.3612.1700 X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3719.2500 X-Complaints-To: abuse@supernews.com Xref: archiver1.google.com comp.lang.ada:37662 Date: 2003-05-22T16:15:05-05:00 List-Id: Robert A Duff wrote in message ... >Vinzent Hoefler writes: >> Currently this thing is written in assembly language, but if I'd ever >> reengineer that in Ada I'd definitely use a (non-binary) modular type >> for the index then (and an array with 16 entries instead). Of course, >> as you pointed out, I could do the modulo arithmetic by hand, but why >> if I can let the compiler handle it? > >Because it makes the code easier to understand if the "mod" is explicit. I agree, especially because the generated code for modular types is ugly. My personal opinion is that wrap-around semantics for unsigned types is a mistake. Ada is about safety, and there is no safety in 2+2=1. I thought and still think that we should have added unsigned integer types with overflow, and then had a special package with wrap-around types of the full sizes for those rare cases where you need such functionality. Virtually every time I use a modular type, I end up tracking down some bug at runtime that would have been caught had there been an overflow check. (Typically in the creation of an array index or the like.) Most of the these types are 'indexes' (handles) that have to fit in a particular size, and I often write checks like: if Index-1 > 0 then Index := Index - 1; end if; which is wrong for a modular type. (Consider Index=0). Randy.