DStyle: Braces on same line

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jul 13 07:52:59 PDT 2014


On Sun, Jul 13, 2014 at 11:32:23AM +0200, Joseph Rushton Wakeling via Digitalmars-d-learn wrote:
> On 12/07/14 21:01, Danyal Zia via Digitalmars-d-learn wrote:
> >I noticed that in Andrei's talks and his book, he used braces on the
> >same line of delcaration, however Phobos and other D libraries I know
> >use braces on their own line. Now I'm in a position where I need to
> >take decision on coding style of my library and I get accustomed to
> >use braces on same line but I'm worried if that would make my library
> >less readable to other D users.
> >
> >Should I worry about it? Or is that's just a debatable style that
> >won't really matter if it's persistent throughout library?
> 
> As long as your coding style is self-consistent, then it really
> doesn't matter a lot.  In particular this choice of bracing style is a
> very minor issue that people are well used to having to deal with.
> 
> However, I do think there's value in deliberately matching the code
> style of the standard library, as it extends the volume of public D
> code with a common style.  So unless you have a strong personal
> preference, I'd go with that.

I had my own style before, but after I started contributing to Phobos, I
found it a pain to keep switching back and forth between styles (and to
convert styles before submitting PR's), so eventually I decided to just
adopt Phobos style for all my D code, including my personal projects.
That way I never have to worry again about which project is in what
style, but everything is consistently the same style.

It also helps that my previous supervisor at my work also used a similar
style, which was different from my own, so I already had to adapt my
style to his in the past. That was what convinced me that other inferior
styles than my own had any merit at all. ;-)

At the end of the day, though, as long as your style is consistent
within a project, it's Good Enough(tm). There are far weightier issues
of semantics to worry about than fretting over syntax.


T

-- 
Verbing weirds language. -- Calvin (& Hobbes)


More information about the Digitalmars-d-learn mailing list