bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [OT] styles.


From: Nicola Pero
Subject: Re: [OT] styles.
Date: Sat, 8 Dec 2001 18:10:19 +0000 (GMT)

> > As a side note, I think the coding style helps with preventing silly
> > syntaxtical errors, but the compiler helps more :-)
> 
> Not C compilers. 
> 
> 
> 
> > both of you agree (and I do as well) that "while (condition)" followed by
> > a ';' not enclosed by brackets - '{', '}' - is bad coding style - so I
> > suppose both of you would be happy if the compiler would emit a warning
> > upon finding "while (condition)" followed by ';' without the brackets
> > around the ';'.  That would detect the typo whatever style you use -
> > wherever you put your newlines and your spaces.
> 
> That  would imply  changing the  syntax of  C.

No - it's like 

 if (object = nil)
   {
     do_something ();
   }

it's perfectly valid C, but the gcc c compiler warns you if you use it
(you turn on/off this behaviour by passing the appropriate -Wsomething
option (which is included by -Wall)).  The compiler compiles it, but warns
you that it suspects your code is wrong - you have to underline you really
want it, by writing

 if ((object = nil))
   {
     do_something ();
   }

to have it compiled without warnings.

In the same way, it could warn when it finds 

 while (condition);
   {
     do_something ();
   }

it valid C, but suspicious - you would have to underline you really want
that ';' by writing

 while (condition) { ; }
   {
     do_something ();
   }

if this hypotethical -W option was used.

I guess because some people (including gcc people probably) actually
*like* to write

  while (condition)
    ;

I doubt such a -W option would ever be accepted into the mainstream gcc c
compiler ... so I should stop dreaming about it :-)




reply via email to

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