| |
 | Posted by Jonathan M Davis in reply to Dejan Lekic | Permalink Reply |
|
Jonathan M Davis 
Posted in reply to Dejan Lekic
| On Saturday, March 8, 2025 8:34:03 AM MST Dejan Lekic via Digitalmars-d wrote:
> Thanks Paul! So do you think people who are working on libraries, ie. code that is supposed to be used by a wider D developer audience, should follow the D Style document?
The style guide is largely broken into two parts - the rules about how to name symbols, and the additional formatting rules for contributing to official projects such as Phobos or druntime.
The naming rules are rules that every public library should be following if the developers working on it want to fit into the D ecosystem, and some programmers will complain if a library does not follow the official naming guidelines (whereas some other progammers won't care much). Ideally, everyone would be following the naming guidelines in the style guide, but some people prefer not to for a variety of reasons. And of course, when you're dealing with bindings to other languages, you can't always follow the D naming conventions.
On the other hand, the formatting rules in the guide are almost entirely aimed at contributions to official D source code, and there's no reason to follow those if you don't want to (outside of contributions to official D source code). It has no impact on users of a library, and it really only matters to folks contributing to it. So, whatever formatting rules you follow when writing a library should be based on what the contributors to that library want to do.
There is a bit about general whitespace stuff at the top of the style guide which is not specific to official D sources (e.g. using 4 spaces for indentation and not using tabs), and prior to the Phobos style guide stuff added later on, it was all that the style guide said about formatting. So, maybe it should be moved to the Phobos section, but it does provide a nice default for those who don't feel strongly about it. Ultimately though, it doesn't matter to the users of a library, whereas the naming conventions directly impact those users.
Of course, for projects that are not made public libraries, even the naming rules arguably don't need to be followed, though it's arguably a good habit to get into.
- Jonathan M Davis
|