Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2001:
[Freeciv-Dev] Re: PATCH: AI cleanup Version 2
Home

[Freeciv-Dev] Re: PATCH: AI cleanup Version 2

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxxxxxxx
Cc: Raahul Kumar <raahul_da_man@xxxxxxxxx>, Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx>, freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: PATCH: AI cleanup Version 2
From: Petr Baudis <pasky@xxxxxxxxxxx>
Date: Sun, 25 Nov 2001 12:14:03 +0100

> If we do so we have to have:
>  - to do it for all code
yes, we just have to start somewhere :-)
>  - guidelines first
yes
> 
> Doing it at some part of the code based on your personal idea of how
> does it look nice is not ok. We all have personal idea of how does the
> code have to look but have to formalize this before we go to change
> this. I really hope we can get a discussion going which will produce
> such guidelines. Here are some questions for the start:
> 
>    * init vars
>        int foo(struct city *punit)
>        {
>          int x=punit->x;
>        } 
> or
>        int foo(struct city *punit)
>        {
>          int x;
> 
>          x=punit->x;
>        }
I think the second will be better, it's more clear.

>    * empty line after vars
>        int x;
>        x=3; 
> or
>        int x;
> 
>        x=3;
Empty line, absolutely.

>    * comments
>        x=3; /* assign 3 to x */ 
> or
>        /* assign 3 to x */
>        x=3;
I prefer first, unless the command or comment will be really long, or unless we
will describe larger part of code obviously.

>    * extra {} on iterates
It would be good. At least to help editors to autoindent them etc. And for
clarity too.

   * spaces around assignment
       x=3;
or
       x = 3;

I would prefer the second one.

   * spaces around conditionals
       if(x == 3){
or
       if( x == 3 ){
or
       if (x == 3) {

Third one seems best to me.

   * spaces around delimiters
       a(b,c);
       for (b=0;b<c;b++)
or
       a(b, c);
       for (b = 0; b < c; b++)

I vote for the second one.

I like this, it looks we will at last be able to get into sync and i will be
able to produce patches which you will be willing accept :-). And the code
will be readable enough to optimize it etc.

-- 

                                Petr "Pasky" Baudis

UN*X programmer, UN*X administrator, hobbies = IPv6, IRC
Real Users hate Real Programmers.
Public PGP key, geekcode and stuff: http://pasky.ji.cz/~pasky/


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