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-7-bit Path: g2news2.google.com!news1.google.com!news.glorb.com!solaris.cc.vt.edu!news.vt.edu!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Should representation clauses be complete for each bit? Date: Wed, 20 Jul 2011 13:27:58 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <73c10395-ec4f-4a02-b0fc-e35bc14424fa@e18g2000vbx.googlegroups.com> <17c212b1-d0a6-498a-a381-71188a67ec65@a10g2000yqn.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1311182880 4539 192.74.137.71 (20 Jul 2011 17:28:00 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 20 Jul 2011 17:28:00 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:8CzEmBCdeCWCvIXwil+UOGC3SX4= Xref: g2news2.google.com comp.lang.ada:21214 Date: 2011-07-20T13:27:58-04:00 List-Id: okellogg writes: > On 20 Jul., 16:51, Robert A Duff wrote: >> [...] >> > IMHO it would be a real gain if we could explicitly mention the unused >> > bits in the rep spec. >> >> I think the unused bits should be explicitly declared. > > My use case originates from a bit packed communication protocol where > the standard requires spare bits interspersed among the useful data. > However the API of the driver shall not expose these spare fields. I see. But that could happen with any component -- it doesn't have to be "spare" and set to zero. What if the protocol requires "set this 3-bit gap to all 1's"? Or what if there's a checksum component, which is set by the driver just before shipping the thing over the wire -- in that case, you wouldn't want to expose the checksum to clients. Perhaps this is what you really want (note that this is illegal for all sorts of reasons): type T1 is record One : Boolean; Tooth : Boolean; Ree : Boolean; end record; type T2 is new T1 with private; -- not Ada! private type T2 is new T1 with record Gap1 : Bits2; -- must be zero Gap2 : Bits11; -- must be zero end record with Predicate => T.Gap1 = 0 and T.Gap2 = 0; for T1 use record pragma Complete_Representation; One at 0 range 0..0; Tooth at 0 range 3..3; Ree at 0 range 15..15; end record; for T2 use record pragma Complete_Representation; Gap1 at 0 range 1..2; Gap2 at 0 range 4..14; end record; - Bob