little thing - D and phobos naming conventions

Sean Kelly sean at f4.ca
Fri Oct 27 06:59:16 PDT 2006


Brian Hay wrote:
> I'm new to D so please forgive my ignorance if indeed that's what it is.
> 
> One thing I like about C#.NET and Java is the consistency and 
> readability of language keywords and framework classes and methods etc, 
> despite the extra verbosity. These languages conform to strict, verbose 
> naming conventions e.g. upper camel case for classes, lower camel case 
> for methods and variables.
> 
> Having said that, I still prefer D (and the development philosophy 
> behind it) but, for example, some library method names are inconsistent 
> and mostly (but not always) follow the legacy C/C++ conventions of 
> lowercase everything and abbreviate to sometimes incoherent acronyms 
> wherever possible. I think this makes code less readable, but I know 
> this is a subjective opinion.
> 
> 
> Example inconsistencies:
> 
>   phobos.std.string
> 
>     toSting() (lower camel case)
>     tolower() (all lower case)
> 
>     iswhite() (all lower case)
>     isNumeric() (lower camel case)
>     inPattern() (lower camel case)
> 
>     tr() not immediately clear what these abbreviations mean
>     atoi() what is the aversion to a little more verbosity?

This is largely a result of the naming convention evolving over time, 
and portions of Phobos being somewhat old.  Phobos code should indeed 
follow the D Style Guide.

> Other than the "D Style Guide" doc for coders (which phobos doesn't seem 
> to conform to), is there a particular naming convention for the D 
> language and standard libraries themselves and what is the rationale 
> behind it? (I'm presuming it's to make the language more familiar to 
> C/C++ coders)

Not really.  Note that some libraries have adopted a somewhat modified 
form.  Mango CamelCases module names, for example.  I've been talking to 
Kris a bit recently and we've been working towards formalizing the 
convention a bit, but we have yet to put it into writing.

> Everything else about D is so cool, modern, well-designed and 
> cutting-edge but some of this naming is so "old school". I know I'm 
> being anal and this shouldn't get on my nerves ... but alas it does.

Consistency is rarely a bad thing in programming :-)


Sean



More information about the Digitalmars-d mailing list