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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!217.73.144.45.MISMATCH!feeder2.ecngs.de!ecngs!feeder.ecngs.de!feeder.news-service.com!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Efficiency of code generated by Ada compilers Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1jmwhfp.roo31ybayx2bN%csampson@inetworld.net> Date: Sun, 8 Aug 2010 20:11:44 +0200 Message-ID: <1bvxgxfzyz1yx.iljsdhfrwzuf.dlg@40tude.net> NNTP-Posting-Date: 08 Aug 2010 20:11:44 CEST NNTP-Posting-Host: ef60fbfd.newsspool4.arcor-online.net X-Trace: DXC=M]:aOR?O[a8^cW`WBF>WQ<4IUK[ On Sun, 8 Aug 2010 10:13:51 -0700, Charles H. Sampson wrote: > Robert A Duff wrote: > >> Gene writes: >> >>> In some cases, a built-in Ada construct will generate better code than >>> a "hand-coded" equivalent in C++. An example I ran into recently was >>> incrementing a modular type. In Ada, you say I := I + 1;, and the >>> compiler takes care of "wrapping" to zero. In C++, I've frequently >>> seen people write i = (i + 1) % n; to simulate the same operation in >>> the absence of modular types. >> >> You will see me writing "I := (I + 1) mod N;" (for signed >> integer I) in Ada. ;-) >> > I'm surprised, Bob. Are you saying that you signed integers in > preference to a modular type for a variable that cycles? Sometimes it has to be that way because modular types do not support non-static bounds. E.g.: procedure Foo (N : Positive) is type M is mod 2**N; -- You cannot do that! -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de