Learning D - first steps and best practices

Jonathan M Davis jmdavisProg at gmx.com
Wed Oct 2 01:50:41 PDT 2013


On Wednesday, October 02, 2013 10:38:10 qznc wrote:
> On Wednesday, 2 October 2013 at 03:28:59 UTC, Jonathan M Davis
> 
> wrote:
> > On Wednesday, October 02, 2013 03:19:19 Jesse Phillips wrote:
> >> For me, if the program didn't format brackets on the same line
> >> I
> >> wouldn't use it. If you start making things configurable, may
> >> as
> >> well improve indent's support for D.
> > 
> > Whereas I'd hate to have to write code that didn't have braces
> > on their own
> > line. It's far better for us both to be able to write code the
> > way that we
> > want than try and force standard formatting rules of some kind.
> > IMHO, they add
> > little to no value and definitely make coding less enjoyable.
> 
> My vision: Jonathan checks out Jesses code to fix a bug. On
> opening the file his editor automatically reformats to
> braces-on-own-line. When committing the fix, a pre-commit hook
> reformats to the project-specific style braces-on-same-line.
> Everybody is happy. :)

Personally, I don't think that that's particularly realistic, but it's far 
from the first time that someone has suggested that sort of thing. And giving 
the inherent flaws in code formatters, I think that this sort of thing is 
doomed to failure.

> Of course, there are edge cases, where automatic formatting
> should be broken. However, I think we should let them be and
> adapt. I also add code sometimes, just to remove a compiler
> warning like "unused argument". Likewise, I am fine with minor
> noise in exchange for consistent styling like described above.

Whereas I care way more about being able to format code the way I want than I 
do about consistent styling.

But code formatting is arguably very much a flamebait topic.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list