Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2001:
[Freeciv-Dev] Re: Voting results for first part of style guide questionn
Home

[Freeciv-Dev] Re: Voting results for first part of style guide questionn

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Cc: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: Voting results for first part of style guide questionnaire
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 3 Dec 2001 22:21:09 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Mon, Dec 03, 2001 at 03:18:30PM -0500, vze2zq63@xxxxxxxxxxx wrote:
> Raimar Falke wrote:
> 
> > Gregory Berkolaiko has put together the results of the first part of
> > the style guide questionnaire:
> 
> 
> 10 B or C
> 11B?
> 12A
> 13E
> 14C
> 
> >   /* A */
> >   /* blah
> >      blah blah
> >      blah */
> >   if (x==0) 
> >     return 1;
> > 

> 10A can be reformatted automatically by indent.

Good to know.

> > int foo11(int x)
> > {
> > 
> >   /* A (always braces) */
> >   switch(x) {
> >   case 2:
> >     {
> >       return 2;
> >     }
> >   case 3:
> >     {
> >       int d = 5;
> >       return d-x;
> >     }
> >   }
> > 
> >   /* B (braces where needed) */
> >   switch(x+3) {
> >   case 2:
> >     return 2;
> >   case 3:
> >     {
> >       int d = 5;
> >       return d-x;
> >     }
> >   }
> > 
> >   /* C (no extra local variables) */
> > 
> >   {
> >     int d;
> >     switch(x) {
> >     case 2:
> >       return 2;
> >     case 3:
> >       d = 5;
> >       retrun d-x;
> >     }
> >   }
> > }
> 
> 
> by 11A, do you mean to *always* but braces into *every* switch, or just 
> that a switch must have all braces or no braces?

I would assume the former. But I agree that the latter makes more
sense.

> > int foo13(void)
> > {
> > 
> >   /* A */
> >   while (*i++) {
> >     continue;
> >   }
> > 
> >   /* B */
> >   while (*i++) {
> >   }
> > 
> >   /* C */
> >   while (*i++) {}
> > 
> >   /* D */
> >   while (*i++);
> > 
> >   /* E */
> >   while(*i++) {
> >     /* nothing */
> >   }
> > 
> >   /* F */
> >   /* !disallow such constructs! */
> > }
> 
> 
> This seems to be getting a bit arbitrary.  13E looks the most legible - 
> but such constructs should IMO be avoided except where they're truly 
> needed.  A bigger question might be between:
> 
> for(i=0, j=1; i<=10; i++, j *= 2) {
>    /* nothing */
> }
> 
> and
> 
> j=1;
> for (i=0; i<=10; i++) {
>    j *= 2;
> }

Good question indeed. Gregory can you include this question?

> I prefer the latter one

Ack.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Despite all the medical advances of the 20th century, the mortality 
  rate remains unchanged at 1 death per person."


[Prev in Thread] Current Thread [Next in Thread]