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,826cd690cb6a7585 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!o9g2000vbo.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Address and bit mask Date: Tue, 30 Aug 2011 03:58:48 -0700 (PDT) Organization: http://groups.google.com Message-ID: <26a278ac-d8b7-4ec9-937b-e182a153ee56@o9g2000vbo.googlegroups.com> References: <71159ccc-bf20-4fcf-a7f1-3b90629c1ecb@l4g2000vbv.googlegroups.com> <87fwkk0zv7.fsf@ludovic-brenta.org> <2cbc5514-122b-4e8a-9ba0-a699e4f874ec@t5g2000yqj.googlegroups.com> NNTP-Posting-Host: 153.98.68.197 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1314701928 31111 127.0.0.1 (30 Aug 2011 10:58:48 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 30 Aug 2011 10:58:48 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: o9g2000vbo.googlegroups.com; posting-host=153.98.68.197; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESRCNK X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101206 Red Hat/3.6-2.el5 Firefox/3.6.13,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20736 Date: 2011-08-30T03:58:48-07:00 List-Id: Ludovic Brenta wrote: > milouz wrote on comp.lang.ada: >> =A0 p =3D (char*) (((unsigned long)p + ALIGN_MASK) & ~ALIGN_MASK); >> How do you write that in Ada ? > > You don't. Please take that seriously. Whenever I see this kind of thing in an Ada program during formal code review, I reject it outright. C is a *bad* language. It does not allow you to specify an alignment or the size of your elements, so it forces you to do address arithmetic. Ada does not have these limitations, so you can say what you are doing. (Also: the reason why you simulate the modulo operator (% in C) with two bitwise operations, bitwise and and bitwise not, escapes me). Transliterating a bad C program into the Ada syntax results in a bad "C in Ada" program; hence the rejection and the very formal "you don't". Please do not take the above as an attempt to disparage you; what you wrote is perfectly idiomatic C. I only wanted to point out that even perfectly idiomatic C is still bad. That's not your fault; you are simply the victim of bad language design. -- Ludovic Brenta.