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,36b302576d78847a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local02.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Thu, 20 Jul 2006 18:12:43 -0500 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: Subject: Re: How do you bitwise operations in Ada '83 and '95 Date: Thu, 20 Jul 2006 18:13:26 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Message-ID: NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-bQUNpKhpG/WnTtdfXFnv5m9rti87QnxCgzV4G2xEK+pz647Aebn+vTgLucnxMAmNDxQRE17VL3lztGP!3kpqZjLwjMlH5GJ9US1oPtjUoC/UHpRnR6uxsPRhTZai75mt4quYwLWaxgfFNmzBOU8xr2dS11l3!awvC0l9DmFm3WA== X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.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.32 Xref: g2news2.google.com comp.lang.ada:5847 Date: 2006-07-20T18:13:26-05:00 List-Id: "Marius Amado-Alves" wrote in message news:mailman.42.1153428092.30988.comp.lang.ada@ada-france.org... > > Surely a record rep clause, and then simple usage of its > > components, is more readable, and more likely to be correct, and even more > > likely to generate optimized code, than source code littered with complex > > arithmetic expressions. > > Actually, in this case, no. Time needs an order relation. Implemented > as a record you have to write the relation functions--and you can > botch there. True enough. > Implemented as a modular type the predefined relation > functions are gratis--and surely correct. Only if you've carefully laid out the order of the bits so that will work. Which is much more likely to ruin the alignment of the bit-field components (an important part of maximum performance). > And the expressions are not > complex. Once you get the masks and magnitudes right, it's simply > > Part := (Whole and Mask) / Magnitude. But that's for each component. Surely you do other operations (like difference in seconds) where the expressions are far more complex? All-in-all, I prefer the record representation. (Case in point: the Janus/Ada Calendar.Time implementation is a 64-bit record type.) But there may be exceptions - and, in any case, if the type is properly encapsulated, it's not that big of a deal either way (no one should be looking at the raw representation of times no matter what they are). Randy.