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 Path: g2news1.google.com!postnews.google.com!l6g2000yqb.googlegroups.com!not-for-mail From: Phil Clayton Newsgroups: comp.lang.ada Subject: Re: Efficiency of code generated by Ada compilers Date: Tue, 10 Aug 2010 05:26:25 -0700 (PDT) Organization: http://groups.google.com Message-ID: <049ff595-3a53-48f3-8001-0d5cf1db0d2a@l6g2000yqb.googlegroups.com> References: <1jmwhfp.roo31ybayx2bN%csampson@inetworld.net> NNTP-Posting-Host: 91.110.236.107 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1281443185 8629 127.0.0.1 (10 Aug 2010 12:26:25 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 10 Aug 2010 12:26:25 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: l6g2000yqb.googlegroups.com; posting-host=91.110.236.107; posting-account=v7gx3AoAAABfjb9m5b7l_Lt2KVEgQBIe User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-GB; rv:1.9.0.15) Gecko/2009102704 Fedora/3.0.15-1.fc10 Firefox/3.0.15,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:13053 Date: 2010-08-10T05:26:25-07:00 List-Id: On Aug 8, 9:51=A0pm, Robert A Duff wrote: > P.S. Can anybody recall the definition of "not" on modular > types, when the modulus is not a power of 2, without > looking it up? =A0Hint: It makes no sense. =A0The only feature > that's worse than "modular types" is "modular types with a > non-power-of-2 modulus". =A0;-) I have the identity not X + 1 =3D -X ingrained on my brain because I wrote too much in assembly language! I haven't checked (honest!) but I'm sure Ada just uses this identity to define "not" for modular types, i.e. not X =3D -X - 1 (rhs wraps around) In my view, this is still useful when the modulus is not a power of two, it's just that "not" is a terrible name for the operation. Only yesterday, I was working in another language with arrays starting at index 0 and needed the elements in reverse: the required effect was achieved by subscripting from the end rather than the start. Had I been working in Ada with an array indexed by a modular type, the effect of reversing the elements could have been achieved by replacing A(I) with A(not I) which I think that is nicer than A(-I - 1) provided people have the intuitive understanding that "not" is effectively an operator that reverses the elements of a modular type. In the other language I was using, I effectively had to write A(A'Length - I - 1) (not valid Ada, of course.) Perhaps "reverse" would be a better name for the operator "not" when the modulus is not a power of two? Phil