Boost logo

Boost :

From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-04-14 06:15:12


----- Original Message -----
From: "Paul A Bristow" <pbristow_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Monday, April 14, 2008 11:26 AM
Subject: Re: [boost] Enum naming conventions

>
>
>>-----Original Message-----
>>From: boost-bounces_at_[hidden]
>>[mailto:boost-bounces_at_[hidden]] On Behalf Of Maciej Sobczak
>>Sent: 14 April 2008 08:25
>>To: boost_at_[hidden]
>>Subject: [boost] Enum naming conventions
>>
>>Hi,
>>
>>Is there an established naming convention for enum names in Boost?
>>I don't see anything truly consistent.
>>
>>Consider this:
>>
>>enum eGrays { eBlack, eDarkGray, eGray, eLightGray, eWhite };
>>
>>Is this commonly accepted by the Boost community?
>>If not, what alternative naming for the above would you propose?
>
> Jake Voytko faced a similar, but more complicated difficulty with naming
> SVG colors
>
> // -----------------------------------------------------------------
> // Deals with colors that have special names. The reason that the
> // underscore separator convention does not match the normal Boost format
> // is that these names that are specified by the SVG standard.
> // http://www.w3.org/TR/SVG/types.html#ColorKeywords
> // tan is also renamed to tanned to avoid clash with function tan in
> math.h
> // -----------------------------------------------------------------
> enum svg_color_constant
> {
> aliceblue, antiquewhite, aqua, aquamarine, azure, beige,
> bisque, black, blanchedalmond, blue, blueviolet, brown,
> <... snipped>
> skyblue, slateblue, slategray, slategrey, snow, springgreen,
> steelblue,
> <and things got worse when we got to tan!
> // tan,
> // Note that tan would clash with geometric tan in math.h!
> global names are evil!
> tanned, teal, thistle, tomato, turquoise, violet,
> ...
>
> I don't think Boost have even *banned* camel mode - just deprecated it.
>
> So
>
> enum grays { gray_black, gray_dark, gray, gray_light...}
>
> or
>
> enum grays {black_gray, dark_gray, gray_gray, light_gray...}
>
> would both seem only a little longer and *much* easier to read?
>
> Or is it a stronger 'this is an enum' marker that you are trying to
> achieve?
>
> Paul

In C++0x enuma have its own namespace.
why not emulate this with namespace. There is a lot of enums in boost
following this.

namespace grays {
 enum type { black, dark, gray, light...};
}

The declaration of a variable is a little bit artificial, ...
    grays::type v;

The enumeration follows the C++0x syntax.
    v= grays::back;

When moving to C++0x you could do a replacement of grays::type and declare
it as before
    enum type { black, dark, gray, light...};
_____________________
Vicente Juan Botet Escriba


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk