From: Stefan Soos <stefan.soos@gmx.de>
Subject: Re: gnatcheck
Date: Tue, 23 Dec 2008 17:53:22 +0100
Date: 2008-12-23T17:53:22+01:00 [thread overview]
Message-ID: <gir523$ppp$1@online.de> (raw)
In-Reply-To: 5897d4c8-eeb0-40cb-808b-09d8cf4d2a1a@s9g2000prg.googlegroups.com
Ludovic Brenta wrote:
> On Dec 23, 5:22 pm, Stefan Soos <stefan.s...@gmx.de> 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
next prev parent reply other threads:[~2008-12-23 16:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-22 20:21 gnatcheck Stefan Soos
2008-12-23 4:19 ` gnatcheck John B. Matthews
2008-12-23 16:22 ` gnatcheck Stefan Soos
2008-12-23 16:30 ` gnatcheck Ludovic Brenta
2008-12-23 16:53 ` Stefan Soos [this message]
2008-12-23 17:06 ` gnatcheck Ed Falis
2008-12-24 20:03 ` gnatcheck Stephen Leake
2008-12-23 19:49 ` gnatcheck Robert A Duff
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox