[Fwd: Re: [Y-devel] Technical Notes]

ychris at amshey.net ychris at amshey.net
Fri Feb 20 19:35:08 GMT 2004


On Fri, Feb 20, 2004 at 04:11:02PM +0100, JP Dinger wrote:
> On Thu, Feb 19, 2004 at 10:58:50PM +0000, Matt Wilson wrote:
> > On Thu, 2004-02-19 at 22:04, Nitin S Kumar wrote:
... <some stuff about style> ...
Braces of 
 if(foo) {
   bar();
 }
are more vertically compact, making it easier to see an entire
section of code at once and encouraging the use of blank lines
to make code readable (because inserting blank lines is that
much less painful).

Braces of
 if(foo)
 {
   bar();
 }
make the brace-matching more obvious at a distance and eliminate
many stupid mistakes of changing if(foo) bar(); to if(foo) { bar(); baz(); }

Neither is 'right' or 'better', and which to use depends mostly on
what a personal preference calls 'readable', and trying to advocate
one leads only to holy wars.

In any case, the style we -will- use is,

  if(foo)
    {
      bar();
    }

Why? Because that's the style Mark wrote the code in, and none of you
can stop him from running it through a c formatter with his favorite
settings so you might as well do it that way from the start. ;)
If you want to convince him to change the style, try for something that
isn't too terribly alien to what he writes naturally... 

As for,

  if(foo)
    {
       many_bars();
    } // foo

This is very bad. If you must have a tail comment, use /* foo */ -
yes, gcc supports //, yes // is probably in several standards now,
no, not every cc on every *nix believes in //.

Right now, Y is for Linux, (and maybe BSD), but if it's ever going
to replace X, it has to be portable across *nix-land. It may be that
gcc-isms will creep in anyway, but unless people are willing to 
-require- gcc version N to build Y, I suggest we avoid doing so when
possible.

(Also, grep shows there are currently no // comments in the code,
 vaguely indicating they go against what established code style there
 is.)

--Chris








More information about the Y-devel mailing list









2026 © www.Y-Windows.Org - All Rights Reserved