Should D file end with newline?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sun Feb 10 02:12:43 UTC 2019


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





More information about the Digitalmars-d-learn mailing list