Naming Conventions & Style Guide?

Jonathan M Davis jmdavisProg at gmx.com
Sat Jan 22 20:21:46 PST 2011


On Saturday 22 January 2011 15:58:47 %u wrote:
> Is there any particular reason that Phobos uses ALL_CAPS (such as
> FunctionAttributes.NOTHROW) and PascalCase (such as Endian.BigEndian) for
> enums, and yet the D Style Guide recommends lowerCamelCase?

Differences in who wrote the code and when. Some of the code in Phobos likely 
pre-dates the style guide and other code might be written by a developer who 
wasn't actually paying attention to the style guide. Overall, while the code in 
Phobos is generally pretty similar in style, the developers have sometimes been 
a bit lax in following any specific style, and there has been some talk of fixing 
that.

My guess in this case that either the enums in question pre-date the style guide 
(Endian.BigEndian probably does) or that the developer in question was just 
doing what is more typical in other languages - which is naming constants in all 
caps - and didn't remember that that's not how it's typically done in D. The 
style guide is the sort of thing that people are likely to read once and forget 
about - particularly if it's very close to what they do normally. There has been 
some cleanup going on in naming things according to the style guide, so those 
may get renamed at some point. I really don't think that there's really any big 
reason though as to why the don't currently match the style guide.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list