Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2001:
[Freeciv-Dev] Re: Coding Guideline RFC
Home

[Freeciv-Dev] Re: Coding Guideline RFC

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx>
Cc: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: Coding Guideline RFC
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 26 Nov 2001 10:48:13 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Sun, Nov 25, 2001 at 05:03:54PM +0000, Gregory Berkolaiko wrote:
> /*************** 
>  * 1: init vars 
>  ***************/
> 
> /* A */
> int foo1a(struct city *punit)
> {
>   int x = punit->x;
> }

Because it is shorter.

> /**************************
>  * 2: empty line after vars 
>  **************************/
> 
> /* B */
> int foo2b(void)
> {
>   int x;
> 
>   x = 3;
> }

More clear.

> /****************
>  * 3: comments 
>  ****************/
> 
> /* B */
> int foo3b(int x)
> {
>   /* assign 3 to x */
>   x = 3;
> }

Because it can be more easily expand if the room isn't enough. See
also <http://www.uwsg.iu.edu/hypermail/linux/kernel/0101.2/0799.html>

> /**************************
>  * 4: extra {} on iterates 
>  **************************/

>   /* A */
>   unit_list_iterate(pcity->units_supported, punit) {
>     kill(punit);
>   } unit_list_iterate_end;
> 
> /****************************************** 
>  * 5: unnecessary braces after conditionals 
>  ******************************************/
> int foo5(int x)
> {
> 
>   /* A */
>   if (x == 3) {
>     return;
>   }
> }
> 
> /**************************************************** 
>  * 6: unnecessary braces after conditionals with else 
>  ****************************************************/
> int foo6(int x)
> {
> 
>   /* A */
>   if (x == 3) {
>     return 1;
>   } else {
>     return 0;
>   }
> }

4, 5 and 6 are the same. Reason: can be more easily changed.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "It is not yet possible to change operating system by writing
  to /proc/sys/kernel/ostype."              sysctl(2) man page


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