Should D file end with newline?
Cym13
cpicard at openmailbox.org
Sun Feb 10 09:06:50 UTC 2019
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
If you used a text editor or IDE to write that final closing
brace then I'm pretty confident it does add the newline character
at the end. That won't result in an empty line on display. Try
using an hex editor to check if you're curious.
More information about the Digitalmars-d-learn
mailing list