Is phobos too fluffy?

Seb seb at
Thu Sep 17 17:49:39 UTC 2020

On Thursday, 17 September 2020 at 15:51:18 UTC, Andrei 
Alexandrescu wrote:
> As wc -l counts, phobos has some 330 KLOC:
> $ wc -l $(git ls-files '*.d') | tail -1
>   331378 total
> I noticed many contributors are fond of inserting empty lines 
> discretionarily, sometimes even in the middle of 2-5 line 
> functions, or right after opening an "if" statement. The total 
> number of empty lines:
> $ git grep '^$' $(git ls-files '*.d') | wc -l
>    38503
> So Phobos has 11.62% empty lines in it, on average one on every 
> 9 lines of code. I find that a bit excessive, particularly 
> given that our coding convention uses brace-on-its-own line, 
> which already adds a lot of vertical space. Here's the number 
> of lines consisting of only one brace:
> git grep '^ *[{}] *$' **/*.d | wc -l
>    53126
> That's 16% of the total. Combined with empty lines, we're 
> looking at a 27.65% fluff factor. Isn't that quite a bit, even 
> considering that documentation requires empty lines for 
> paragraphs etc?
> Today's monitors favor width over height and I didn't yet get 
> to the point of rotating my monitor for coding purposes. (It's 
> also curved, which would make it awkward.) Would it be 
> reasonable to curb a bit on the fluff factor? E.g. there should 
> never be two consecutive empty lines, and code blocks shorter 
> than x lines should have no newlines inside.

We shouldn't have these discussions.
We should just use a code formatting tool (see e.g. how 
successful black was in the Python world - and be done with.

So IMHO the only productive discussion here is how we can get 
dfmt (  (or a new tool) 
in a shape, s.t. it can be applied automatically.

Alternatively, for your specific request, there was [1], but I 
since gave up on enforcing such style issues manually. As I 
mentioned, a tool should handle this task for you.


More information about the Digitalmars-d mailing list