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!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 17:21:55 -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> <6666bbe0-8485-4b8d-b077-70ffea630151@l37g2000yqd.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: pcls6.std.com 1311196915 4195 192.74.137.71 (20 Jul 2011 21:21:55 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 20 Jul 2011 21:21:55 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:dY1Zh5UI9DVF4b4V8q7jGccS/6Y= Xref: g2news2.google.com comp.lang.ada:21220 Date: 2011-07-20T17:21:55-04:00 List-Id: okellogg writes: >> � � � � with Predicate => T.Gap1 = 0 and T.Gap2 = 0; > > I'd imagine that a default assignment at Gap1 and Gap2 would suffice? > Gap1 : Bits2 := 0; Yeah, maybe. >> � �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; >> > > I believe the compiler would warn about incomplete representation at > T1? I think "pragma Complete_Representation" means "require every component to be mentioned", not "require every bit from 0 to 'Size-1 to be used up. Not sure. > 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? I'm assuming the package would export functions to create T2 objects and operate on them. Or maybe it would be more convenient to derive the other way round (put the gaps in the parent type), so clients could say (Parent_Type with One | Tooth => True, Ree => False), assuming Parent_Type defaults the gaps to 0, as you suggested. - Bob