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!news1.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nntp.club.cc.cmu.edu!feeder.erje.net!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!gegeweb.org!aioe.org!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Efficiency of code generated by Ada compilers Date: Mon, 9 Aug 2010 17:59:45 +0000 (UTC) Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: J4HSNf9Eqj44wTz1J3b8lQ.user.speranza.aioe.org X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: Tom's custom newsreader Xref: g2news1.google.com comp.lang.ada:12995 Date: 2010-08-09T17:59:45+00:00 List-Id: >> 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. Interesting. I think the opposite. The explicit mod versions take a computer-centric, rather than problem-centric, view, which is the opposite of the usual "Ada approach". They are also subject to the possible error of failing to write the "mod" part, whereas with modular types the compiler has the responsibility to remember to do the mod operation.