Coding Standards

Jonathan M Davis jmdavisProg at gmx.com
Fri Jul 15 08:56:05 PDT 2011


On Friday 15 July 2011 16:09:06 Russel Winder wrote:
> On Fri, 2011-07-15 at 16:25 +0200, Trass3r wrote:
> > Am 15.07.2011, 09:53 Uhr, schrieb Jonathan M Davis <jmdavisProg at gmx.com>:
> > > The brace on its own line and the line length limit need to be added
> > > as
> > > notes for Phobos, but I'm not sure that they really need to be put
> > > in
> > > the guide
> > 
> > Brace on its own line really should be put there.
> > It adds a lot to the readability of nested code.
> > 
> > And there's lots of D code using that awkward
> > if () {
> > }
> > 
> > style. Gross!
> 
> Actually I think that the above is the only acceptable style of brace
> placement, especially compared to
> 
> if ( )
> {
> }
> 
> which is anathema, no code should ever be allowed to use it.
> 
> (If you read this as a troll, then you have missed the point of
> moralization by satire.)

LOL. Whereas I would argue that that is exactly the style of bracing which 
should be used. This is exactly why we shouldn't be trying to push any kind of 
global standard for D with regards to formatting. You will never get everyone 
to agree on it even within a relatively small group.

The current style guide primarily covers naming conventions, which actually 
affect APIs and are far more important.

Incidentally, bracing on its own line is one of the few formatting rules that 
Phobos requires (primarily because braces is one of the few areas of 
formatting which causes code to get really ugly if it varies all over the 
place).

- Jonathan M Davis


More information about the Digitalmars-d mailing list