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!news2.google.com!news1.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Efficiency of code generated by Ada compilers Date: Mon, 09 Aug 2010 09:53:13 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1281361978 32710 192.74.137.71 (9 Aug 2010 13:52:58 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 9 Aug 2010 13:52:58 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:uq8gtDPwVjB2xtmjOL6/wrpmK4Q= Xref: g2news1.google.com comp.lang.ada:12981 Date: 2010-08-09T09:53:13-04:00 List-Id: tmoran@acm.org writes: >> And it would be desirable, because in most cases the explicit >> "mod" (or "%") is more readable. > > I := Ring_Indices'succ(I); > vs > I := (I + 1) mod Ring_Size; > or > Bearing := Bearing + Turn_Angle; > vs > Bearing := (Bearing + Turn_Angle) mod 360; The explicit "mod"s are more readable, I think. For angles, you probably want a fixed-point type, and there's no such thing as modular fixed-point types in Ada. There was a proposal to add that to Ada 2005, but I think ARG decided not to do that, IIRC. Note that you can always write functions that do a "mod", if that's what you want -- Next_Ring_Index, or "+" on fixed-point angles. - Bob