Is anyone working on a D source code formatting tool?

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Sun Jan 11 11:19:34 PST 2015


On 1/11/2015 4:47 AM, Russel Winder via Digitalmars-d wrote:
>> Next question - standalone tool, or built in to dmd (like Ddoc)?
> Also why in DMD and not in LDC or GDC?

It would be in the DMD front end, so LDC and GDC would it automatically.


>> 1. people expect this sort of thing these days
>
> Thanks to Python PEP-8 and Go, yes. Personalized code formatting is
> increasingly a thing of the past, programming languages are now
> opinionated and fascist when it comes to formatting. Even if the rules
> are wrong.

The rules are always going to be wrong. But in this case, that's ok.


>> 2. it tends to end bikeshedding arguments about the right way to
>> format things
> Except when the tool implements the wrong style.

Sometimes it's better to just conform.


>> 3. it'll help standardize the format of D code in the D repositories
> Even if it is the wrong formatting standard?
>
> I have to admit that the Phobos format rules make the code look
> appallingly ugly to me, sufficiently so that I really do not want to
> work on that codebase. I guess I am biased towards K&R C (which I use
> to drive my C++ style), Java and Go.

Really? Like what? After many years of arguing about formatting myself, I 
decided that I had better things to waste my time on.


>> 4. it's simply nice and convenient!
> Working with Go in Emacs or LiteIDE is a bit of a joy as you get full
> reformatting on save. Fortunately I only have two main gripes with the
> Go formatting style, but no-one has a choice, use the Go style as
> dictated by the Go team at Google or do not use Go.

So you decided to conform rather than not use Go.

(Anyhow, I suggest that gofmt is only mandatory if you wish to contribute to 
offical Go code, not for your own projects.)



More information about the Digitalmars-d mailing list