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!news2.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.nethere.com!news.nethere.com.POSTED!not-for-mail NNTP-Posting-Date: Sun, 08 Aug 2010 12:13:53 -0500 Newsgroups: comp.lang.ada Subject: Re: Efficiency of code generated by Ada compilers From: csampson@inetworld.net (Charles H. Sampson) Date: Sun, 8 Aug 2010 10:13:51 -0700 Message-ID: <1jmwhfp.roo31ybayx2bN%csampson@inetworld.net> References: User-Agent: MacSOUP/2.8.2 (Mac OS X version 10.4.11 (PPC)) X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-RQlwdsg3vP7nGutMPylmbj7LcAaHQbnctev93kPfj62JsKcYBjXaezRu+j6yjWnROqfadCcKEftJV9V!TmB4jY0Tz+QGfQfV5JCOM/NOPQ5IFoAL+7zfqwP3LWNcUhaEBjn4Rt4U4J6Ahrk6UcJCMHQfy+33!+BGKKVOdc14va4y6tpdCAO1sZNs= X-Complaints-To: abuse@nethere.com X-DMCA-Complaints-To: abuse@nethere.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 Xref: g2news1.google.com comp.lang.ada:12962 Date: 2010-08-08T10:13:51-07:00 List-Id: 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? I use modular-typed variables and, if I've got my engineer's hat on, write I := I + 1; -- Modular variable. Wraps. 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. Charlie -- All the world's a stage, and most of us are desperately unrehearsed. Sean O'Casey