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!newsfeed2.dallas1.level3.net!news.level3.com!panix!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: Sat, 23 Jul 2011 11:12:25 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <73c10395-ec4f-4a02-b0fc-e35bc14424fa@e18g2000vbx.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1311433945 31948 192.74.137.71 (23 Jul 2011 15:12:25 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sat, 23 Jul 2011 15:12:25 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:Lyv0khFB0G5/HCrRgPhqAqvuTns= Xref: g2news2.google.com comp.lang.ada:21298 Date: 2011-07-23T11:12:25-04:00 List-Id: "Randy Brukardt" writes: > I would do this slightly differently (in fact we did, in Claw where we had > this exact problem): > > type T is > record > One : Boolean; > Gap1 : Bits2 := 0; -- must be zero > Tooth : Boolean; > Gap2 : Bits11 := 0; -- must be zero > Ree : Boolean; > end record > with Predicate => T.Gap1 = 0 and T.Gap2 = 0; > > with the same record rep clause. > Then the (correct) aggregates don't need to mention the gaps explicitly: > > with Ada.Assertions; use Ada.Assertions; > procedure P.Main is > -- X : T := (One | Tooth | Ree => True, Gap1 => 0, Gap2 => 0); -- OK > X : T := (One | Tooth | Ree => True, others => <>); -- OK Hmm. That seems reasonable, although it makes me nervous that you might accidentally say: X : T := (One | Tooth => True, others => <>); which evilly leaves junk in Ree. That sort of bug is likely if you add new components to a record. - Bob