D Style document

Paul Backus snarwin at gmail.com
Sat Mar 8 11:30:44 UTC 2025


On Saturday, 8 March 2025 at 10:15:47 UTC, Dejan Lekic wrote:
> Throughout the druntime for an example, enum values and 
> manifest constants are SNAKE_CASE style, while the 
> abovementioned document recommends the camelCase for both: 
> [Naming 
> constants](https://dlang.org/dstyle.html#naming_constants) , 
> [Enum 
> members](https://dlang.org/dstyle.html#naming_enum_members)
>
> So, considering that something as critical to us as the 
> druntime uses a different style, should we perhaps modify the D 
> Style page and change recommended style for constants and enum 
> members to SNAKE_STYLE (which I also prefer)?

D has been around for more than 20 years, and core D projects 
like DMD, druntime, and Phobos contain a lot of old code that 
does not hold up to modern standards. So the fact that SNAKE_CASE 
constants are used in some parts of druntime is not a strong 
argument for using them elsewhere.

Also, druntime in particular uses a lot of `extern(C)` bindings, 
and SNAKE_CASE is the standard way of naming constants in C.

Of course, you don't have to follow the D style guide for your 
own projects if you don't want to. For example, I use tabs for 
indentation in my personal projects, rather than spaces like the 
style guide suggests.


More information about the Digitalmars-d mailing list