[Freeciv-Dev] Re: Coding Guideline --- more variants
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Thu, Nov 29, 2001 at 04:25:55PM +0100, Reinier Post wrote:
> > 11a: always braces
> > switch(a) {
> > case 2:
> > {
> > return 2;
> > }
> > case 3:
> > {
> > int x;
> > ....
> > }
>
> This (11a) is my preference.
> BTW I seem to remember some C compilers or standards don't allow
> such intra-block variable declarations, while I much prefer them myself,
> I even create blocks to introduce them:
AFAIK this is allow by the standard. Nevertheless the code includes
such constructs and there no problem.
> int foo()
> {
> int i;
>
> i=changing(i);
>
> {
> int j;
>
> for (j=0; j<i; ++j) {
> i=foo(j);
> }
> }
>
> return i;
> }
>
> Has this been sorted out? Have we voted on this?
>
> QUESTION 11.5: declarations within blocks
>
> /* A */ all declarations at start
> /* B */ declarations within block if possible
> /* C */ even create blocks to scope declarations where appropriate
>
> My preference: C.
"Use the smallest possible scope". If interpreted in its purest way
this would mean C. However in the case above I wouldn't use C. This
depends on the size and the number of
variables. ai_military_findvictim defines 12 variables at the function
scope. This is too much. However the next function
ai_military_bodyguard uses 6 and this is ok for me.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"From what I am reading Win98 and NT5.0 will be getting rid of all that
crap anyway. Seems that Microsoft has invented something called TCP/IP and
another really revolutionary concept called DNS that eliminates the
netbios crap too. All that arping from browsers is going to go away.
I also hear rumors that they are on the verge of breakthrough discoveries
called NFS, and LPD too. Given enough time and money, they might
eventually invent Unix."
-- George Bonser in linux-kernel
- [Freeciv-Dev] Re: Please vote!, (continued)
- [Freeciv-Dev] Re: Please vote!, Gregor Zeitlinger, 2001/11/30
- [Freeciv-Dev] Re: Please vote!, Vasco Alexandre Da Silva Costa, 2001/11/29
- [Freeciv-Dev] Re: Please vote!, Ross W. Wetmore, 2001/11/30
- [Freeciv-Dev] Coding Guideline --- more variants, Gregory Berkolaiko, 2001/11/28
- [Freeciv-Dev] Re: Coding Guideline --- more variants, Raimar Falke, 2001/11/28
- [Freeciv-Dev] Re: Coding Guideline --- more variants, Raimar Falke, 2001/11/28
- [Freeciv-Dev] Re: Coding Guideline --- more variants, Petr Baudis, 2001/11/28
- [Freeciv-Dev] Re: Coding Guideline --- more variants, Raahul Kumar, 2001/11/29
- [Freeciv-Dev] Re: Coding Guideline --- more variants, Petr Baudis, 2001/11/29
- [Freeciv-Dev] Re: Coding Guideline --- more variants, Reinier Post, 2001/11/29
- [Freeciv-Dev] Re: Coding Guideline --- more variants,
Raimar Falke <=
- [Freeciv-Dev] Re: Coding Guideline --- more variants, Reinier Post, 2001/11/29
- [Freeciv-Dev] Re: Coding Guideline --- more variants, Daniel L Speyer, 2001/11/28
- [Freeciv-Dev] Re: Coding Guideline --- more variants, Raahul Kumar, 2001/11/29
- [Freeciv-Dev] Re: PATCH: AI cleanup Version 2, Raimar Falke, 2001/11/25
- [Freeciv-Dev] Re: PATCH: AI cleanup Version 2, Raahul Kumar, 2001/11/26
- [Freeciv-Dev] Re: PATCH: AI cleanup Version 2, Raimar Falke, 2001/11/26
- [Freeciv-Dev] Re: PATCH: AI cleanup Version 2, Tony Stuckey, 2001/11/26
- [Freeciv-Dev] Re: PATCH: AI cleanup Version 2, Raimar Falke, 2001/11/26
- [Freeciv-Dev] Re: PATCH: AI cleanup Version 2, Raahul Kumar, 2001/11/24
- [Freeciv-Dev] Re: PATCH: AI cleanup Version 2, Petr Baudis, 2001/11/24
|
|