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!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: Wed, 11 Aug 2010 01:42:56 -0500 Newsgroups: comp.lang.ada Subject: Re: Efficiency of code generated by Ada compilers From: csampson@inetworld.net (Charles H. Sampson) Date: Tue, 10 Aug 2010 23:42:54 -0700 Message-ID: <1jn17h6.1q1szxwqifwdkN%csampson@inetworld.net> References: <1jmwhfp.roo31ybayx2bN%csampson@inetworld.net> User-Agent: MacSOUP/2.8.2 (Mac OS X version 10.4.11 (PPC)) X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-0WJnytnzibfagzbMS+JwQIm6pfKJI3WRIsyodd1GPpZXRZSzMvsqWLOjKhP5wmL+bpnWc94429o5lcv!f5hXH8yCyc1XRG31C5xvTlXz7WH9NuyFSw6RRVtyZZYz4IZiIwrcDCLpuHptTGc/xBw75n9brS9y!q90YgwBuXSwNwmClwRtaOP0ZS6t3Rg== 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:13103 Date: 2010-08-10T23:42:54-07:00 List-Id: 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"? > I hope you didn't read my profession of surprise as being the same as "Wow! Bob did something really stupid." I just thought you would be one of the people (like me) who uses every feature of Ada whenever there's an opportunity. For the record, my uses of modular types have been as indexes into circular buffers. I think these buffers have always been my own invention, in support of a requirement but not a requirement in themselves. I'm not sure what I might do if it were natural, or required, to have a circular structure whose lower index is not 0. I learned to program on very slow machines and I've never been able to shake efficiency concerns. I've already thought of a couple of pretty unnatural things to do in order to achieve decent efficiency, efficiency that, as usual, is totally unnecessary in the problem domain. > > ... 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". ;-) Actually, those circular buffers of mine have often had sizes that are not powers of two. The compiler I was using generated pretty decent code for them. Regarding what I read as your main complaint, very late in the Ada 95 effort I submitted a comment that the proposed modular types were an uncomfortable merger of two ideas: modular types and bit twiddling. Since there was no obvious relation between those two ideas (weak cohesion, as it were), I requested that two distinct types be used instead. I have no idea what the ARG thought of the merits of my comment, but even if they thought is was the most brilliant comment they had received, I submitted it much to late to have any hope of its being acted on. Charlie -- All the world's a stage, and most of us are desperately unrehearsed. Sean O'Casey