Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2001:
[Freeciv-Dev] Re: AI cleanup - first wave
Home

[Freeciv-Dev] Re: AI cleanup - first wave

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Petr Baudis <pasky@xxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: AI cleanup - first wave
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 1 Dec 2001 09:40:05 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Sat, Dec 01, 2001 at 12:13:34AM +0100, Petr Baudis wrote:
> > > It is prolly better to do }\nelse if here.
> > I think indent will cover this.
> It really does, it's smarter than I thought.
> 
> > > And if you will run it thru indent anyway...
> > I run the parts which are changed thru indent.
> 90% of functions were changed.
> 
> > > >  A
> > > >   if (is_barbarian(pplayer)) {
> > > >      ....
> > > >   /* If not barbarian, ... */
> > > >   } else {
> > > > 
> > > >  B
> > > >   if (is_barbarian(pplayer)) {
> > > >      ....
> > > >   } else { /* If not barbarian, ... */
> > > > 
> > > >  C
> > > >   if (is_barbarian(pplayer)) {
> > > >      ....
> > > >   } else {
> > > >     /* If not barbarian, ... */
> > > I vote for A ;-).
> > I'm for C.
> Well, if you do
> 
> /* If 1, */
> if (1) {
>   ...
> /* If not 1, */
> } else {
>   ...
> }
> 
> it is IMHO more readable than
> 
> /* If 1, */
> if (1) {
>   ...
> } else {
>   /* If not 1, */
>   ...
> }

Yes I see this problem. One solution is:

/* comment for the whole (if and else branch) */
if(cond) {
 /* comment for the if branch */
 ...
} else {
 /* comment for the else branch */
 ...
}

But this contradicts the only-if case where you usually do:

/* comment for if case */
if(cond) {
  ...
}

And if you add now an else branch you have to move the comment.

        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]