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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,13bec1d6e8f0eeee X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.germany.com!news.belwue.de!peernews!feed.news.schlund.de!schlund.de!news.online.de!not-for-mail From: Stefan Soos Newsgroups: comp.lang.ada Subject: Re: gnatcheck Followup-To: comp.lang.ada Date: Tue, 23 Dec 2008 17:53:22 +0100 Organization: 1&1 Internet AG Message-ID: References: <5897d4c8-eeb0-40cb-808b-09d8cf4d2a1a@s9g2000prg.googlegroups.com> NNTP-Posting-Host: ulmg-5f71d216.pool.einsundeins.de Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit X-Trace: online.de 1230051203 26425 95.113.210.22 (23 Dec 2008 16:53:23 GMT) X-Complaints-To: abuse@einsundeins.com NNTP-Posting-Date: Tue, 23 Dec 2008 16:53:23 +0000 (UTC) User-Agent: KNode/0.99.01 Xref: g2news1.google.com comp.lang.ada:3079 Date: 2008-12-23T17:53:22+01:00 List-Id: Ludovic Brenta wrote: > On Dec 23, 5:22 pm, Stefan Soos wrote: >> Hi, >> Thanks but I've already checked this source, but it's no help to me. >> It describes what gnatcheck does when using the Discriminated_Record >> rule. But I don't know why its a violation. Whats wrong with >> discriminated records? Another example. Predefined_Numeric_Types. I >> know I shouldn't used them. But I know it because a long time ago I >> read it in the ARM. Theres no reference in gnatcheck to the specific >> chapter in the ARM. >> I'd like to improve my code and evolve a good programming habit, but >> it's really hard to google all the rules with no results. >> >> I hope someone can enlighten me. I wish you all a merry christmas, >> Stefan > > I think this is because discriminated records can be variant records, > i.e. some components exist for some values of the discriminant but not > for others. Dealing with such types requires extra care from the > programmer and increases the possibility of Constraint_Error at run > time. Also, they can make the program more difficult to read for > people new to Ada. > > The ARM does not give any advice on "good style"; it only says what is > legal and what is not. Discriminated records are legal and are useful > in a number of situations. > > -- > Ludovic Brenta. So gnatcheck is saying its legal what you're doing but you have to pay attention at some points. What I'm missing in gnatcheck are some hints like yours: Discriminated records aren't evil per se, but you have to take extra care when you're using them as variant records. Without this hint it's pretty useless and confusing, but not a help.If I know the pitfalls of discriminated records, then I can switch off the rule. But what if I don't? Bye, Stefan