Why The D Style constants are written in camelCase?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Wed May 9 15:20:12 UTC 2018


On Wednesday, May 09, 2018 14:12:41 Dmitry Olshansky via Digitalmars-d-learn 
wrote:
> On Wednesday, 9 May 2018 at 09:38:14 UTC, BoQsc wrote:
> > The D Style suggest to camelCase constants, while Java naming
> > conventions always promoted uppercase letter.
> >
> > Is there an explanation why D Style chose to use camelCase
> > instead of all UPPERCASE for constants, was there any technical
> > problem that would appear while writing in all UPPERCASE?
>
> It is D style for standard library. It is mostly arbitrary but in
> general sensible.
> That’s it.

To an extent that's true, but anyone providing a library for use by others
in the D community should seriously consider following it with regards to
public symbols so that they're consistent with how stuff is named across the
ecosystem. It's not the end of the world to use a library that did something
like use PascalCase instead of camelCase for its function names, or which
used lowercase and underscores for its type names, or did any number of
other things which are perfectly legitimate but don't follow the D style.
However, they tend to throw people off when they don't follow the naming
style of the rest of the ecosystem and generally cause friction when using
3rd party libraries.

Stuff like how code is formatted or how internal symbols are named are
completely irrelevant to that, but there's a reason that the D style guide
provides naming conventions separately from saying anything about how Phobos
code should look. The D ecosystem at large is better off if libraries in
general follow the same naming conventions for their public symbols.
Obviously, not everyone is going to choose to follow the official naming
conventions, but IMHO, their use should be actively encouraged with regards
to public symbols in libraries that are made publicly available.

- Jonathan M Davis




More information about the Digitalmars-d-learn mailing list