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,2a34b7ad6c6a0774 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder2.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!news.wiretrip.org!news2.arglkargh.de!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "(see below)" Newsgroups: comp.lang.ada Subject: Re: Efficiency of code generated by Ada compilers Date: Sun, 08 Aug 2010 23:10:38 +0100 Message-ID: References: <1jmwhfp.roo31ybayx2bN%csampson@inetworld.net> Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Trace: individual.net MrKbK5K5LIDvwwK3LgVMiAB2ZLSVqMd8ylpg7v9RWfdzN0jF5k Cancel-Lock: sha1:6XdmaR5UefWVu8yoIioZIrHvuSo= User-Agent: Microsoft-Entourage/12.23.0.091001 Thread-Topic: Efficiency of code generated by Ada compilers Thread-Index: Acs3RogNHzdFlxtUHky1w4LRCnC/Ng== Xref: g2news1.google.com comp.lang.ada:12971 Date: 2010-08-08T23:10:38+01:00 List-Id: On 08/08/2010 21:51, in article wcchbj4j09y.fsf@shell01.TheWorld.com, "Robert A Duff" wrote: > csampson@inetworld.net (Charles H. Sampson) writes: > >> Robert A Duff wrote: >> >> I'm surprised, Bob. Are you saying that you signed integers in >> preference to a modular type for a variable that cycles? > > Yes. Unless I'm forced to use modular for some other reason > (e.g. I need one extra bit). > >> ...I use >> modular-typed variables and, if I've got my engineer's hat on, write >> >> I := I + 1; -- Modular variable. Wraps. > > You're not alone. Even Tucker has advocated using modular > types for this sort of thing. > > But I think an explicit "mod N" is clearer than a comment. > > Variables that cycle are rare, so should be noted explicitly > in the code. And, as Dmitry noted, modular types only work > when the lower bound is 0. It's not unreasonable to have > a circular buffer indexed by a range 1..N. > > See my point? Still "surprised"? > >> but I have to admit that in the heat of battle the comment might be >> omitted. Even in that case, the variable name probably indicates that >> wrapping should be expected. > > - Bob > > P.S. Can anybody recall the definition of "not" on modular > types, when the modulus is not a power of 2, without > looking it up? Hint: It makes no sense. The only feature > that's worse than "modular types" is "modular types with a > non-power-of-2 modulus". ;-) I don't use non-power-of-2 mod types, but I write emulators, and I would be stuffed if I could not declare, e.g.: type KDF9_word is mod 2**48; -- Bill Findlay chez blueyonder.co.uk