Boost logo

Boost :

From: Paul A Bristow (pbristow_at_[hidden])
Date: 2008-04-14 05:26:24


 

>-----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

---
Paul A Bristow
Prizet Farmhouse, Kendal, Cumbria UK LA8 8AB
+44 1539561830 & SMS, Mobile +44 7714 330204 & SMS
pbristow_at_[hidden]
 

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