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!l37g2000yqd.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 12:14:48 -0700 (PDT) Organization: http://groups.google.com Message-ID: <6666bbe0-8485-4b8d-b077-70ffea630151@l37g2000yqd.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 1311189288 20975 127.0.0.1 (20 Jul 2011 19:14:48 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 20 Jul 2011 19:14:48 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: l37g2000yqd.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 (X11; U; Linux i686; en-US; rv:1.9.1.4) Gecko/20091016 SUSE/3.5.4-1.1.2 Firefox/3.5.4,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:21217 Date: 2011-07-20T12:14:48-07:00 List-Id: On Jul 20, 7:27=A0pm, Robert A Duff wrote: > [...] > But that could happen with any component -- it doesn't have to be > "spare" and set to zero. =A0What if the protocol requires "set this > 3-bit gap to all 1's"? =A0Or 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. Yes, I guess you're right. The syntax you propose is much more general and flexible. > Perhaps this is what you really want (note that this is illegal > for all sorts of reasons): > > =A0 =A0type T1 is > =A0 =A0 =A0 record > =A0 =A0 =A0 =A0 =A0One : Boolean; > =A0 =A0 =A0 =A0 =A0Tooth : Boolean; > =A0 =A0 =A0 =A0 =A0Ree : Boolean; > =A0 =A0 =A0 end record; > > =A0 =A0type T2 is new T1 with private; -- not Ada! > private > =A0 =A0type T2 is new T1 with > =A0 =A0 =A0 record > =A0 =A0 =A0 =A0 =A0Gap1 : Bits2; -- must be zero > =A0 =A0 =A0 =A0 =A0Gap2 : Bits11; -- must be zero > =A0 =A0 =A0 end record > =A0 =A0 =A0 =A0 with Predicate =3D> T.Gap1 =3D 0 and T.Gap2 =3D 0; I'd imagine that a default assignment at Gap1 and Gap2 would suffice? Gap1 : Bits2 :=3D 0; > =A0 =A0for T1 use > =A0 =A0 =A0 record > =A0 =A0 =A0 =A0 =A0pragma Complete_Representation; > =A0 =A0 =A0 =A0 =A0One at 0 range 0..0; > =A0 =A0 =A0 =A0 =A0Tooth at 0 range 3..3; > =A0 =A0 =A0 =A0 =A0Ree at 0 range 15..15; > =A0 =A0 =A0 end record; > > =A0 =A0for T2 use > =A0 =A0 =A0 record > =A0 =A0 =A0 =A0 =A0pragma Complete_Representation; > =A0 =A0 =A0 =A0 =A0Gap1 at 0 range 1..2; > =A0 =A0 =A0 =A0 =A0Gap2 at 0 range 4..14; > =A0 =A0 =A0 end record; > I believe the compiler would warn about incomplete representation at T1? Also I guess an upcast from T2 to T1 should do for converting the types but I'm not so sure about the downcast from T1 to T2? -- Oliver