On Sunday, 10 February 2019 at 02:12:43 UTC, Jonathan M Davis wrote:
On Saturday, February 9, 2019 2:19:27 PM MST Victor Porton via Digitalmars- d-learn wrote:
ISO C++ specifies that the C++ file must end with a newline.

Should D file end with newline, too?

No, there is no need to end D files with a newline. I would guess that the vast majority of D files end with a closing brace. I just looked at a bunch of files in the standard library for the heck of it, and almost all of the ones I looked at ended with a closing brace. And those that didn't ended with something like an enum declaration and not a newline. Personally, I don't leave newlines at the end of files, because it looks messy. I don't even recall doing that in C++, though I do recall that there supposedly be a rule about it. It seems like a pretty bizarre requirement to me, but regardless, I'm quite sure that D does not have that requirement.

- Jonathan M Davis

Doing a quick a quick tail on all the source files for dmd, druntime and phobos, I only found 6 source files that ended in a curly brace and 2 ending in a 'g'. All others ended with a newline. Its certainly not required but it is common in the style guides I've seen and I personally have my editor automatically insert a newline.

Reply via email to