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,fd173879a595bde X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Default rep specs for record types - documented?? Date: 13 Nov 2005 20:09:32 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1131930572 17851 192.74.137.71 (14 Nov 2005 01:09:32 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 14 Nov 2005 01:09:32 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:6364 Date: 2005-11-13T20:09:32-05:00 List-Id: Stephen Leake writes: > "Frank J. Lhota" writes: > > > Stephen Leake wrote: > > >> I forgot to add Field_0 to the rep clause, and the compiler put it at > >> the end (where it didn't belong). Most importantly, the compiler > >> didn't warn me. > > > > The fault lies with the code, not the compiler. > > No, the fault lies with me, who wrote the code. The code is, as you > point out, wrong. > > Part of the point of using Ada is to make it harder to make mistakes > like this. That's why I want a warning when I make this mistake. I agree. It would be better if you had to explicitly say "I don't care about field X" if you don't, and the compiler would complain if you just leave X out of the rep clause. I'm not even sure the capability to leave out some components is useful enough to have in the language. > Compare this to a case statement on an enumeration type; the compiler > warns you when you add an enumeral but forget to update the case > statement. Right, or a record aggregate where you add a component. > More importantly, I want the compiler to generate the "reasonable > packed rep clause", not "the most efficient for data storage" or > whatever other criteria it uses in the absence of a rep clause. That would be nice. Record rep clauses are way too detailed for most uses. There ought to be a way to say "use the canonical representation". > This matters more when I'm describing bit fields in a register; > without a rep clause the compiler will use at least a byte for each > field. So the generated rep clause will not be a very good starting > point. You could say "pragma Pack", and then see what the compiler says. But once you've included the rep clause in your source code, it becomes difficult to maintain, whether it was compiler generated or hand written. - Bob