Naming convention in Phobos

Jonathan M Davis jmdavisProg at gmx.com
Tue Mar 8 15:18:25 PST 2011


On Tuesday, March 08, 2011 10:28:11 %u wrote:
> > Fortunately, these are "very not" any kind of <<most logical
> 
> choices>>. Neither according to D's own naming convention, nore
> (imo) according to plain common sense. I have the same kind of use
> case as you, apparently (including even a 'TypeCodes' enum!), and
> thank to D's very weird naming, /I/ can use sensible names for enum
> members and various other symbol series, without resorting to a
> kind of prefix code or such.
> // same names as in the source language, thanx!
> enum TypeCodes
> {
>      Integer,
>      Real,
>      Text,
>      Logical,
>      Array,
>      ...
> }
> 
> 
> Noticed that you capitalized "real", which would have collided with
> the keyword. (My point wasn't that "long" was the best name, but
> that this situation obviously occurs often enough to merit
> consideration of a different casing convention.)

I have _never_ needed to use a primitive type's name (which is obviously a 
keyword) in an enum. _Never_. I'd be very surprised if Phobos ever needed to. I 
have a _very_ hard time believing that this is a common thing to do. And if type 
codes is your example, well type codes are generally considered to be bad 
practice, so I don't really see them as much of a supporting argument.

Regardless, no matter what your naming conventions are, you're going to run into 
places where they don't work quite as well as you'd like. The naming conventions 
that we've been using for Phobos have generally been working quite well. The 
problem is generally that older Phobos code doesn't follow them, but that's 
slowly being fixed. What we've been doing works. And while I think that D code in 
general should follow similar naming conventions, you _are_ perfectly free to 
use whatever naming conventions you like in your own code.

- Jonathan M Davis


More information about the Digitalmars-d mailing list