Boost logo

Boost :

Subject: Re: [boost] underscores in private class member names (was: [local] this_ or _this?)
From: Julian Gonggrijp (j.gonggrijp_at_[hidden])
Date: 2011-04-14 06:31:40


Emil Dotchevski wrote:

> Granted, it is very unlikely _this to be used by the implementation,
> but I've seen compilers defining macros with leading underscore
> followed by a lowercase letter. There is no reason to insist on using
> leading underscores, in global scope or not.

Joshua Juran wrote:

> A name beginning with an underscore not followed by a capital letter is allowable at non-global scope (provided it doesn't contain two consecutive underscores). Such names include _, _1, and _this.

Steven Watanabe wrote:

> The convention is that _xxx is used for placeholders.
> xxx_ is used when xxx is a keyword.

Dear Boosters,

All this talking of underscores makes me wonder about private class
members. Several authors advise to give them names with a prefix
underscore (followed by a lowercase letter). It does seem to have
clear advantages: it visually marks the members as implementation
details, and it also makes it easier to distinguish class member data
from arguments and locally declared variables in member functions.

However, your opinions probably differ wildly on the matter. Would you
consider it good practice to give private class members a name that
starts with _[a-z] (regex)?

-Julian


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