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!news3.google.com!feeder.news-service.com!feeder.erje.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!jacob-sparre.dk!ada-dk.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Should representation clauses be complete for each bit? Date: Fri, 22 Jul 2011 19:13:02 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <73c10395-ec4f-4a02-b0fc-e35bc14424fa@e18g2000vbx.googlegroups.com> <4e26f324$0$6549$9b4e6d93@newsspool4.arcor-online.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1311379985 24910 69.95.181.76 (23 Jul 2011 00:13:05 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Sat, 23 Jul 2011 00:13:05 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109 Xref: g2news2.google.com comp.lang.ada:21276 Date: 2011-07-22T19:13:02-05:00 List-Id: "Robert A Duff" wrote in message news:wcchb6fbs04.fsf@shell01.TheWorld.com... ... > Part of my complaint is that you have to say it twice: > > type Bits2 is mod 2**2; > pragma Assert (Bits2'Size = 2); There is a reason that Ada has constants. ;-) And I have no idea why you are using an Assert here rather than specifying the Size oughtright (I always do that in such cases): Gap1_Size : constant := 2; type Gap1_Bits is mod 2**Gap1_Size with Size => Gap1_Size; This gives a compile-time failure if there is something wrong with the Size, not a runtime one (as Assert does). And it also has the benefit of working (at least if we use the old syntax) on Ada 83 compilers and Ada 95 compilers that never implemented the goofy Ada 95 'Size rules [i.e. Janus/Ada 95]. > OK, now we have a 2-bit type. But we have to specify 2 bits again > in the rep clause: > > Gap1 at 0 range 1..2; Gap1 at 0 range 1 .. Gap1_Size; or to be even more general: Gap1 at 0 range Gap1_Start .. Gap1_Size - Gap1_Start + 1; (We have a number of lines like this in Claw and other programs here.) I understand the complaint here, but I still think that explictly specifying the bit packing in this way is best. The syntax that requires mentioning both the low and high bits is overkill, but that has nothing to do with this particular issue -- it is overkill for *any* record. We really need an alternative shorter syntax for these lines in a record representation clause: Gap1 at 0 bit 1; or something like that. No one ever wants to give the high bound in these clauses -- it's almost pointless and a real pain if it might change (note the most general form given above). Randy.