Why I'm skeptical of auto-formatting

Basile B. b2.temp at gmx.com
Thu May 2 23:26:47 UTC 2019


On Thursday, 2 May 2019 at 22:44:51 UTC, H. S. Teoh wrote:
> I know this is a minority opinion,

No it's not, I'm in the same clique. I rather think that people 
should write with discipline, i.e stick to a brace style, an 
indent style etc. Then the text looks good but they can permit 
themselves extravagances when required.

> and in fact even I myself would regard the following as an 
> exceptional case rather than the norm, but the following 
> unittest from one of my projects, quoted verbatim, is one 
> reason why I'm skeptical of applying code auto-formatting 
> indiscriminately:
>
> ------
>     assert("i*10+j:i<>j=3".parseGridSpec.generateGrid[].map!(p 
> => p.value)
>            .equal(
>     [
>                       -30,
>                  -21, -20, -19,
>             -12, -11, -10,  -9, -8,
>         -3,  -2,  -1,   0,   1,  2, 3,
>               8,   9,  10,  11, 12,
>                   19,  20,  21,
>                        30
>     ]));
> ------
>
> The meaning of the first line is unimportant to the topic at 
> hand (though guesses are welcome :-P).  The main point here is 
> that any auto-formatting tool I know of would not only 
> completely destroy the elegance of the above test, but also 
> pretty much remove all visual traces of why exactly this 
> particular case is being tested and why the given values are 
> the correct ones, as opposed to some arbitrary random sequence 
> of integers.
>
>
> T




More information about the Digitalmars-d mailing list