leading underscore for member names 
July 22nd, 2005, 11:20 AM
| | | |
Somebody with a very regulatory mind in this newsgroup has written
that it's better not to use a leading underscore for class member
names, because names with a leading underscore are used internally by
compilers (well, not so internally, since they appear in header
files).
I personally use the leading underscore (followed by a lower case
letter), which I consider to be much more readable than the trailing
underscore.
My reasoning is that scope resolution works, and if I should get a
clash with a macro (very unlikely, since macros are usually uppercase)
it almost certainly would result in something which won't compile
(could in exceptional cases cause a nuisance when porting to another
platform, but compared with other nuisances...)
Am I wrong? | 
July 22nd, 2005, 11:20 AM
| | | | re: leading underscore for member names
"Walter Tross" <walter@waltertross.com> wrote in message
news:ovg0909nq4sqbk8i1t4pm76hvtuvso2kiq@4ax.com...[color=blue]
> Somebody with a very regulatory mind in this newsgroup has written
> that it's better not to use a leading underscore for class member
> names, because names with a leading underscore are used internally by
> compilers (well, not so internally, since they appear in header
> files).
> I personally use the leading underscore (followed by a lower case
> letter), which I consider to be much more readable than the trailing
> underscore.
> My reasoning is that scope resolution works, and if I should get a
> clash with a macro (very unlikely, since macros are usually uppercase)
> it almost certainly would result in something which won't compile
> (could in exceptional cases cause a nuisance when porting to another
> platform, but compared with other nuisances...)
> Am I wrong?
>[/color]
Two leading underscores or a leading underscore followed by a capital letter
are reserved. But one leading underscore followed by a lower case letter
should be OK. I used to use a leading underscore myself but changed to m_
when I found out that the "m" meant "member" and not "Microsoft". :)
--
Cy http://home.rochester.rr.com/cyhome/ | 
July 22nd, 2005, 11:20 AM
| | | | re: leading underscore for member names
"Walter Tross" <walter@waltertross.com> wrote in message
news:ovg0909nq4sqbk8i1t4pm76hvtuvso2kiq@4ax.com...[color=blue]
> Somebody with a very regulatory mind in this newsgroup has written
> that it's better not to use a leading underscore for class member
> names, because names with a leading underscore are used internally by
> compilers (well, not so internally, since they appear in header
> files).[/color]
[color=blue]
> I personally use the leading underscore (followed by a lower case
> letter), which I consider to be much more readable than the trailing
> underscore.[/color]
[color=blue]
> My reasoning is that scope resolution works, and if I should get a
> clash with a macro (very unlikely, since macros are usually uppercase)
> it almost certainly would result in something which won't compile
> (could in exceptional cases cause a nuisance when porting to another
> platform, but compared with other nuisances...)
> Am I wrong?[/color]
17.4.3.1.2 of the Standard:
Certain sets of names and function signatures are always reserved to the
implementation:
- Each name that contains a double underscore (_ _) or begins with an
underscore followed by an uppercase
letter (2.11) is reserved to the implementation for any use.
- Each name that begins with an underscore is reserved to the implementation
for use as a name in the
global namespace.165)
165) Such names are also reserved in namespace ::std (17.4.3.1).
Regards,
Sumit. | 
July 22nd, 2005, 11:20 AM
| | | | re: leading underscore for member names
"Walter Tross" <walter@waltertross.com> wrote in message
news:ovg0909nq4sqbk8i1t4pm76hvtuvso2kiq@4ax.com...[color=blue]
> Somebody with a very regulatory mind in this newsgroup has written
> that it's better not to use a leading underscore for class member
> names, because names with a leading underscore are used internally by
> compilers (well, not so internally, since they appear in header
> files).
> I personally use the leading underscore (followed by a lower case
> letter), which I consider to be much more readable than the trailing
> underscore.
> My reasoning is that scope resolution works, and if I should get a
> clash with a macro (very unlikely, since macros are usually uppercase)
> it almost certainly would result in something which won't compile
> (could in exceptional cases cause a nuisance when porting to another
> platform, but compared with other nuisances...)
> Am I wrong?
>[/color]
I use them for the same reason. And you're not wrong provided you stick to
class members.
john | 
July 22nd, 2005, 11:21 AM
| | | | re: leading underscore for member names
On Thu, 29 Apr 2004 08:45:59 +0530, "Sumit Rajan"
<sumitrajan@myrealbox.com> wrote:
[color=blue]
>
>"Walter Tross" <walter@waltertross.com> wrote in message
>news:ovg0909nq4sqbk8i1t4pm76hvtuvso2kiq@4ax.com.. .[color=green]
>> Somebody with a very regulatory mind in this newsgroup has written
>> that it's better not to use a leading underscore for class member
>> names, because names with a leading underscore are used internally by
>> compilers (well, not so internally, since they appear in header
>> files).[/color]
>[color=green]
>> I personally use the leading underscore (followed by a lower case
>> letter), which I consider to be much more readable than the trailing
>> underscore.[/color]
>[color=green]
>> My reasoning is that scope resolution works, and if I should get a
>> clash with a macro (very unlikely, since macros are usually uppercase)
>> it almost certainly would result in something which won't compile
>> (could in exceptional cases cause a nuisance when porting to another
>> platform, but compared with other nuisances...)
>> Am I wrong?[/color]
>
>
>17.4.3.1.2 of the Standard:
>Certain sets of names and function signatures are always reserved to the
>implementation:
>
>- Each name that contains a double underscore (_ _) or begins with an
>underscore followed by an uppercase
>letter (2.11) is reserved to the implementation for any use.[/color]
I dont'quite understand the double underscore thing, since in your
writing there is a space between the two underscores. Does it refer to
a leading AND a trailing underscore or does it refer to two
consecutive underscores (as I guess it does)?
I don't use either, in any case, so this does not affect me, I think.
[color=blue]
>- Each name that begins with an underscore is reserved to the implementation
>for use as a name in the
>global namespace.165)
>
>165) Such names are also reserved in namespace ::std (17.4.3.1).[/color]
Since I only use the leading underscore for my class members, I'm
safely out of the global namespace, and out of ::std too.
Maybe I should start the "Leading Underscore for Member Names" (LUMN)
movement :-)
Walter | 
July 22nd, 2005, 11:21 AM
| | | | re: leading underscore for member names
"Walter Tross" <walter@waltertross.com> wrote in message
news:qbo190tasuev2ba4ii6et1fo8486t6m0oj@4ax.com...[color=blue]
> On Thu, 29 Apr 2004 08:45:59 +0530, "Sumit Rajan"
> <sumitrajan@myrealbox.com> wrote:
>[color=green]
> >
> >"Walter Tross" <walter@waltertross.com> wrote in message
> >news:ovg0909nq4sqbk8i1t4pm76hvtuvso2kiq@4ax.com.. .[color=darkred]
> >> Somebody with a very regulatory mind in this newsgroup has written
> >> that it's better not to use a leading underscore for class member
> >> names, because names with a leading underscore are used internally by
> >> compilers (well, not so internally, since they appear in header
> >> files).[/color]
> >[color=darkred]
> >> I personally use the leading underscore (followed by a lower case
> >> letter), which I consider to be much more readable than the trailing
> >> underscore.[/color]
> >[color=darkred]
> >> My reasoning is that scope resolution works, and if I should get a
> >> clash with a macro (very unlikely, since macros are usually uppercase)
> >> it almost certainly would result in something which won't compile
> >> (could in exceptional cases cause a nuisance when porting to another
> >> platform, but compared with other nuisances...)
> >> Am I wrong?[/color]
> >
> >
> >17.4.3.1.2 of the Standard:
> >Certain sets of names and function signatures are always reserved to the
> >implementation:
> >
> >- Each name that contains a double underscore (_ _) or begins with an
> >underscore followed by an uppercase
> >letter (2.11) is reserved to the implementation for any use.[/color]
>
> I dont'quite understand the double underscore thing, since in your
> writing there is a space between the two underscores. Does it refer to
> a leading AND a trailing underscore or does it refer to two
> consecutive underscores (as I guess it does)?
> I don't use either, in any case, so this does not affect me, I think.[/color]
Greetings!
My guess is the same, too. I guess it should be "__".
The space between the underscores exists in the Standard, too. (All I did
was to copy-and-paste). Maybe it was presented that way for better clarity
in print versions of the Standard.
[color=blue]
>[color=green]
> >- Each name that begins with an underscore is reserved to the[/color][/color]
implementation[color=blue][color=green]
> >for use as a name in the
> >global namespace.165)
> >
> >165) Such names are also reserved in namespace ::std (17.4.3.1).[/color]
>
> Since I only use the leading underscore for my class members, I'm
> safely out of the global namespace, and out of ::std too.
>
> Maybe I should start the "Leading Underscore for Member Names" (LUMN)
> movement :-)[/color]
We would need to make LUMN pronunciation-friendly (Or it would become a
crime against humanity: the whole world has to do with a name like TCP/IP)?
Maybe LUMeN would do the trick!
Regards,
Sumit.
[color=blue]
> Walter[/color] |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,689 network members.
|