D pullrequest review process rant

Timothee Cour thelastmammoth at gmail.com
Wed May 8 20:27:08 PDT 2013


Can you point me to a few places in phobos where you worry the
autoformatter will be undesirable ?

We use something like clang_format on a large code base and it just works.
For the rare cases where one wants to override the autoformatter, we
can include a special tag in comments.
The need for those annotations should be quite rare.
Example:

// @NOFORMAT_BEGIN
void my_specially_formatted_fun(){
  int[]x=[0,1,2,
            4,5,6];
}
// @NOFORMAT_END

or with a single statement, which shall apply to the following logical block:
// @NOFORMAT_BLOCK
void my_specially_formatted_fun(){
  int[]x=[0,1,2,
            4,5,6];
}
(Another option would be user defined attributes although I doubt
that's a good use of those).

Note, comments shouldn't be touched typically, but could be formatted
on demand with dfmt begin_line end_line (clang_format has such an
option).
As for line breaks, I would argue that a much better behavior is to
simply use soft line wraps, as supported by most modern editors, so
there would be no need for them (I personally hate hard line wraps
which creates unnecessary overflow/underflow problems in comments and
many other issues).

I personally don't care much for minute formatting details but some
do, so having such a tool makes formatting related problems just go
away.
I believe it can be done for D with almost no need for special
override markers, and the benefits will largely outweigh the
inconvenience of few places requiring them.


More information about the Digitalmars-d mailing list