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,f7c38a023cf370dc X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!a10g2000yqn.googlegroups.com!not-for-mail From: okellogg Newsgroups: comp.lang.ada Subject: Re: Should representation clauses be complete for each bit? Date: Wed, 20 Jul 2011 09:58:14 -0700 (PDT) Organization: http://groups.google.com Message-ID: <61e3eeed-23a0-47be-a18e-00684812204d@a10g2000yqn.googlegroups.com> References: <73c10395-ec4f-4a02-b0fc-e35bc14424fa@e18g2000vbx.googlegroups.com> <17c212b1-d0a6-498a-a381-71188a67ec65@a10g2000yqn.googlegroups.com> NNTP-Posting-Host: 79.240.95.92 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1311181094 2391 127.0.0.1 (20 Jul 2011 16:58:14 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 20 Jul 2011 16:58:14 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: a10g2000yqn.googlegroups.com; posting-host=79.240.95.92; posting-account=a23u_AkAAAB-Xz81hSqodYsmJRrMwioK User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.18) Gecko/20110614 Firefox/3.6.18,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:21213 Date: 2011-07-20T09:58:14-07:00 List-Id: On Jul 20, 6:24=A0pm, "Dmitry A. Kazakov" wrote: > On Wed, 20 Jul 2011 08:29:18 -0700 (PDT), okellogg wrote: > > My use case originates from a bit packed communication protocol where > > the standard requires spare bits interspersed among the useful data. > > My advise would be not to use representation clauses. They cannot deal wi= th > protocols anyway. Wow. I thought this is what rep clauses are there for. > Think about protocol error handling, special patterns of > bits, checksums etc. It also makes no sense in letting the wire-specific > types to spoil the rest of your code with unchecked unions, nonnative > scalars, misaligned data, nul-terminated rubbish etc. Any performance gai= n > compared to explicit parsing would be negligible and may turn to a loss > later when the data are used. Mind you, I am talking in hindsight, this is not something I invented. I.e. I've implemented the mentioned protocol already. I share your concerns wrt a high level interface but I'm talking about a driver API here. OTOH, I guess I could go along with "if it's a low level interface, why not make the spare bits visibile too." At this level, the user must know precisely what he's doing anyway, and that filling data into spare fields isn't going to buy anything. It's just extra baggage that nobody really needs. Oliver