public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Coding style
@ 2003-05-02 10:10 Mark Kettenis
  2003-05-02 17:32 ` Joel Brobecker
  2003-05-02 18:46 ` Andrew Cagney
  0 siblings, 2 replies; 4+ messages in thread
From: Mark Kettenis @ 2003-05-02 10:10 UTC (permalink / raw)
  To: gdb

Hi folks,

I've been noticing that some folks (most notably Andrew :-) have been
very "economical" in the use of empty lines in function bodies.  I
know that the GNU coding standards say that one should not use too
many of those, but I think there are good reasons to keep with the
tradition of seperating the declaration of local variables from
geneuine code by an empty line, e.g.:

int
max_register_size (struct gdbarch *gdbarch)
{
  struct regcache_descr *descr = regcache_descr (gdbarch);

  return descr->max_register_size;
}

instead of:

int
max_register_size (struct gdbarch *gdbarch)
{
  struct regcache_descr *descr = regcache_descr (gdbarch);
  return descr->max_register_size;
}

I keep finding the first much more legible.  AFAICT all GNU projects
that take the coding standards serious use that style.  By the way,
using whitespace to logically group lines together within a function
body is generally a good idea too.  Well, IMHO of course...

Anyway, I hope no one will object if add a few extra newlines
here'n'there when I feel it's appropriate?

Mark

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

* Re: Coding style
  2003-05-02 10:10 Coding style Mark Kettenis
@ 2003-05-02 17:32 ` Joel Brobecker
  2003-05-02 18:46 ` Andrew Cagney
  1 sibling, 0 replies; 4+ messages in thread
From: Joel Brobecker @ 2003-05-02 17:32 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb

> I know that the GNU coding standards say that one should not use too
> many of those, but I think there are good reasons to keep with the
> tradition of seperating the declaration of local variables from
> geneuine code by an empty line, e.g.:

I agree with Mark.

-- 
Joel

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

* Re: Coding style
  2003-05-02 10:10 Coding style Mark Kettenis
  2003-05-02 17:32 ` Joel Brobecker
@ 2003-05-02 18:46 ` Andrew Cagney
  2003-05-03  9:54   ` Richard Earnshaw
  1 sibling, 1 reply; 4+ messages in thread
From: Andrew Cagney @ 2003-05-02 18:46 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb

> (most notably Andrew :-)

It depends on the day of the week.  Sometimes my new code contains lots 
of blank lines, sometimes it doesn't.

Btw, the blank line here:

int
max_register_size (struct gdbarch *gdbarch)
{
   struct regcache_descr *descr;

   descr = regcache_descr (gdbarch);
   return descr->max_register_size;
}

makes sense, but when contracted into:

> int
> max_register_size (struct gdbarch *gdbarch)
> {
>   struct regcache_descr *descr = regcache_descr (gdbarch);
> 
>   return descr->max_register_size;
> }

or:

> int
> max_register_size (struct gdbarch *gdbarch)
> {
>   struct regcache_descr *descr = regcache_descr (gdbarch);
>   return descr->max_register_size;
> }

things get pretty arbitrary.  Is "descr" a declaration or code body?

Anyway, if your new code adds blank lines, I can't remove them without 
rewritting the function - the requirement to keep white space changes 
separate from fixes stops this.

Andrew

PS: This is somewhat ironic, Stan was oft to complain that my code 
contained too many blank lines :-)


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

* Re: Coding style
  2003-05-02 18:46 ` Andrew Cagney
@ 2003-05-03  9:54   ` Richard Earnshaw
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Earnshaw @ 2003-05-03  9:54 UTC (permalink / raw)
  To: Andrew Cagney; +Cc: Mark Kettenis, gdb, Richard.Earnshaw


> makes sense, but when contracted into:
> 
> > int
> > max_register_size (struct gdbarch *gdbarch)
> > {
> >   struct regcache_descr *descr = regcache_descr (gdbarch);
> > 
> >   return descr->max_register_size;
> > }
> 
> or:
> 
> > int
> > max_register_size (struct gdbarch *gdbarch)
> > {
> >   struct regcache_descr *descr = regcache_descr (gdbarch);
> >   return descr->max_register_size;
> > }
> 
> things get pretty arbitrary.  Is "descr" a declaration or code body?

I find the break helpful to delimit the extent of the declarations.  I'm 
not too bothered if there is code in the declarations, provided it's 
straight-forward initializations, not complex conditional operations and 
the like.

R.

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

end of thread, other threads:[~2003-05-03  9:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-02 10:10 Coding style Mark Kettenis
2003-05-02 17:32 ` Joel Brobecker
2003-05-02 18:46 ` Andrew Cagney
2003-05-03  9:54   ` Richard Earnshaw

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).