comp.lang.ada
 help / color / mirror / Atom feed
* gnatcheck
@ 2008-12-22 20:21 Stefan Soos
  2008-12-23  4:19 ` gnatcheck John B. Matthews
  2008-12-23 19:49 ` gnatcheck Robert A Duff
  0 siblings, 2 replies; 8+ messages in thread
From: Stefan Soos @ 2008-12-22 20:21 UTC (permalink / raw)


Hello,

when I use gnatcheck on my project, I get a bunch of error messages for coding standard violations. Where can I find more infos what the different rules mean? For example, I get "declaration of discriminanted record". Now I'd like to know why this is a violation and where in the RM I can read more about it. Can I make gnatcheck to be more verbose or specific?

Thanks in advance,
Stefan



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: gnatcheck
  2008-12-22 20:21 gnatcheck Stefan Soos
@ 2008-12-23  4:19 ` John B. Matthews
  2008-12-23 16:22   ` gnatcheck Stefan Soos
  2008-12-23 19:49 ` gnatcheck Robert A Duff
  1 sibling, 1 reply; 8+ messages in thread
From: John B. Matthews @ 2008-12-23  4:19 UTC (permalink / raw)


In article <gioss0$q92$1@online.de>, Stefan Soos <stefan.soos@gmx.de> 
wrote:

[...]
> when I use gnatcheck on my project, I get a bunch of error messages for 
> coding standard violations. Where can I find more infos what the different 
> rules mean? For example, I get "declaration of discriminanted record". Now 
> I'd like to know why this is a violation and where in the RM I can read more 
> about it. Can I make gnatcheck to be more verbose or specific?

I'd start with the GNAT User's Guide section on gnatcheck:

<http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gnat_ugn_unw/>

-- 
John B. Matthews
trashgod at gmail dot com
http://home.roadrunner.com/~jbmatthews/



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: gnatcheck
  2008-12-23  4:19 ` gnatcheck John B. Matthews
@ 2008-12-23 16:22   ` Stefan Soos
  2008-12-23 16:30     ` gnatcheck Ludovic Brenta
  2008-12-24 20:03     ` gnatcheck Stephen Leake
  0 siblings, 2 replies; 8+ messages in thread
From: Stefan Soos @ 2008-12-23 16:22 UTC (permalink / raw)


John B. Matthews wrote:

> In article <gioss0$q92$1@online.de>, Stefan Soos <stefan.soos@gmx.de>
> wrote:
> 
> [...]
>> when I use gnatcheck on my project, I get a bunch of error messages
>> for coding standard violations. Where can I find more infos what the
>> different rules mean? For example, I get "declaration of
>> discriminanted record". Now I'd like to know why this is a violation
>> and where in the RM I can read more about it. Can I make gnatcheck to
>> be more verbose or specific?
> 
> I'd start with the GNAT User's Guide section on gnatcheck:
> 
> <http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gnat_ugn_unw/>
> 
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



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: gnatcheck
  2008-12-23 16:22   ` gnatcheck Stefan Soos
@ 2008-12-23 16:30     ` Ludovic Brenta
  2008-12-23 16:53       ` gnatcheck Stefan Soos
  2008-12-24 20:03     ` gnatcheck Stephen Leake
  1 sibling, 1 reply; 8+ messages in thread
From: Ludovic Brenta @ 2008-12-23 16:30 UTC (permalink / raw)


On Dec 23, 5:22 pm, Stefan Soos <stefan.s...@gmx.de> wrote:
> John B. Matthews wrote:
> > In article <gioss0$q9...@online.de>, Stefan Soos <stefan.s...@gmx.de>
> > wrote:
>
> > [...]
> >> when I use gnatcheck on my project, I get a bunch of error messages
> >> for coding standard violations. Where can I find more infos what the
> >> different rules mean? For example, I get "declaration of
> >> discriminanted record". Now I'd like to know why this is a violation
> >> and where in the RM I can read more about it. Can I make gnatcheck to
> >> be more verbose or specific?
>
> > I'd start with the GNAT User's Guide section on gnatcheck:
>
> > <http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gnat_ugn_unw/>
>
> 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.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: gnatcheck
  2008-12-23 16:30     ` gnatcheck Ludovic Brenta
@ 2008-12-23 16:53       ` Stefan Soos
  2008-12-23 17:06         ` gnatcheck Ed Falis
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Soos @ 2008-12-23 16:53 UTC (permalink / raw)


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




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: gnatcheck
  2008-12-23 16:53       ` gnatcheck Stefan Soos
@ 2008-12-23 17:06         ` Ed Falis
  0 siblings, 0 replies; 8+ messages in thread
From: Ed Falis @ 2008-12-23 17:06 UTC (permalink / raw)


The idea behind gnatcheck is to enforce organization-specific coding  
standards.  It comes with a set of default rules there were of interest to  
certain customers developing safety-critical software, whose coding  
standards excluded certain constructs that are difficult to certify for  
safety applications.  You should go through the list and turn off those  
rules that are irrelevant to your situation.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: gnatcheck
  2008-12-22 20:21 gnatcheck Stefan Soos
  2008-12-23  4:19 ` gnatcheck John B. Matthews
@ 2008-12-23 19:49 ` Robert A Duff
  1 sibling, 0 replies; 8+ messages in thread
From: Robert A Duff @ 2008-12-23 19:49 UTC (permalink / raw)


Stefan Soos <stefan.soos@gmx.de> writes:

> 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?

There's nothing wrong with discriminated records.  If gnatcheck
complains about something, that doesn't mean it's bad -- it just means
that somebody wanted to avoid or take careful note of that feature.
That might have been a silly idea, or it might have been a wise
decision for that particular project.  It doesn't necessarily
apply to your project.

You have to decide on your own which stylistic rules to follow.
An Ada textbook or tutorial might help, but gnatcheck itself
will not give you this information.

> 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.

It's usually/often a good idea to define your own numeric types.
Not always.  And of course the person who designed type String
in package Standard didn't take that advice.

> 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.

That's not really what gnatcheck is for.

- Bob



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: gnatcheck
  2008-12-23 16:22   ` gnatcheck Stefan Soos
  2008-12-23 16:30     ` gnatcheck Ludovic Brenta
@ 2008-12-24 20:03     ` Stephen Leake
  1 sibling, 0 replies; 8+ messages in thread
From: Stephen Leake @ 2008-12-24 20:03 UTC (permalink / raw)


Stefan Soos <stefan.soos@gmx.de> writes:

>> I'd start with the GNAT User's Guide section on gnatcheck:
>> 
>> <http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gnat_ugn_unw/>
>> 

> 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?

I consider this a bug in the gnatcheck manual; you should send a
report to AdaCore. They might even answer your question :)

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-12-24 20:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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       ` gnatcheck Stefan Soos
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox