Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] Re: AI - cleaning (Was: Re: [UPDATE] Corecleanup_08 patch)
Home

[Freeciv-Dev] Re: AI - cleaning (Was: Re: [UPDATE] Corecleanup_08 patch)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx>, rf13@xxxxxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: AI - cleaning (Was: Re: [UPDATE] Corecleanup_08 patch)
From: Raahul Kumar <raahul_da_man@xxxxxxxxx>
Date: Wed, 10 Oct 2001 06:00:58 -0700 (PDT)

--- Gregory Berkolaiko <gberkolaiko@xxxxxxxxxxx> wrote:
>  --- Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> wrote: 
> >
> > Opinions about this?
> > 
> >    * init vars
> >        int foo(struct city *punit)
> >     {
> >     int x=punit->x;
> >     } 
> > or
> >        int foo(struct city *punit)
> >     {
> >     int x; 
> > 
> >     x=punit->x;
> >     }
> 
> initialization at the time of declaring var can sometimes help very much
> to understand the code.  E.g.
>   struct *pplayer = unit_owner(punit);
> is nice and clear.  Some rules can be made wrt the ordering, like "first
> come pure declarations then declarations + initializations"
> 
> So I vote 1 here.
> 

I agree with Greg. 1 for me as well. Raimar, have you checked out the gnome
coding style? It's at

http://developer.gnome.org/doc/guides/programming-guidelines/book1.html

It looks quite nice, with a few mods Freeciv could adopt it. I love the style
of asserts from glib

g_return_if_fail (condition)

    Returns from the current function if condition is false.

g_return_val_if_fail (condition, value)
    Returns the specified value from the current function if condition is
false.

g_assert (condition)

    Aborts the program if condition is false.

g_assert_not_reached ()

    Aborts the program if the macro is ever called.
 
Not sure I like the idea of identing everything 8 spaces though.

> >    * empty line after vars
> >         int x;
> >     x=3; 
> > or
> >         int x;
> > 
> >     x=3;
> 
> empty line helps.
> vote 2.
>

Same.
 
> 
> >    * comments
> >        x=3; /* assign 3 to x */ 
> > 
> > or
> >        /* assign 3 to x */
> >        x=3;
> 
> either way, unless commentary is very long in which case 2.
>

I prefer selecting one comment method, and I'd really prefer 2.
 
> > 
> >    * extra {} on iterates
> 
> extra {} do not hurt but I don't really care.
>

No idea, whatever other people want.
 
> G.
> 
> ____________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
> or your free @yahoo.ie address at http://mail.yahoo.ie
> 


__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com


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