_underscrore

_underscrore

Post by Digby Mill » Sat, 05 Mar 2005 20:27:37


Can anyone add some credence to the use of the underscore in the C++
programming language, what are it's uses, compared to a language like
FORTRAN where programs took on such a well layed out and logical
appearance in their structure, programmers are led to beleive that such
structures in the C++ language are temporary, will these features ever
be rationalized are with the complexity of programming as it now stands
are these permanent fixtures.

Thanks Regards Digby Millikan
 
 
 

_underscrore

Post by Chris Uzda » Sun, 06 Mar 2005 00:42:45

"Digby Millikan" < XXXX@XXXXX.COM > writes:

[snip]

The underscore's only use is as part of a valid set of characters that
can comprise an identifier. It can also appear as data inside a
string, but it's not really "used" in that context.

The only thing special about underscores in C++ identifiers is when
they are in the first position of the identifier or whenever two are
next to each other, in the global namespace. In both cases the
identifier is reserved and the user is not allowed to write programs
using names with that style.

To simplify the rules, it's easiest to adopt the following two
guidelines:

* never use leading underscores in any identifier name of code you
write.

* never use two underscores immediately next to each other in any
identifiers.

While a little more strict than the standard requires (since it
ignores the namespace issue) it's easy to adopt and apply to code, and
not hard to explain. Adhereing to the standard is harder to explain,
and thus less easy to implement or have a whole team adopt.

--
Chris (TeamB);

 
 
 

_underscrore

Post by Digby Mill » Thu, 24 Mar 2005 11:54:53


What I actually meant was who's decision was it to use underscores to start
an identifier, it seems a bit of an irregular way to spell a command
statement,
was it that commands which used the underscore where only meant to be
temporary parts of the C++ language?

Regards Digby
 
 
 

_underscrore

Post by Chris Uzda » Thu, 24 Mar 2005 12:10:54

"Digby Millikan" < XXXX@XXXXX.COM > writes:


It's a way to ensure that the names used internally by the compiler
and standard library will not have conflicts with user-defined names.
That's why they're reserved. (Many names can exist in the std
namespace to help prevent such collisions, but preprocessor macros are
also names, and they do not respect any sort of namespace.)

Additionally, language extensions are to be introduced with
double-leading-underscore to avoid all such collisions. User-code in
the global namespace is not allowed to have any names with
double-underscore in them (with nothing seperating the 2 underscores),
nor are user programs allowed to start with a leading underscore.

--
Chris (TeamB);
 
 
 

_underscrore

Post by Hendrik Sc » Fri, 25 Mar 2005 02:16:49


I don't think this is restricted to the
global namespace. (Which makes sense, as
keywords aren't scope sensitive in std
C++.)



What do you mean with that?

Schobi

--
XXXX@XXXXX.COM is never read
I'm Schobi at suespammers dot org

"The presence of those seeking the truth is infinitely
to be prefered to those thinking they've found it."
Terry Pratchett
 
 
 

_underscrore

Post by Chris Uzda » Fri, 25 Mar 2005 06:02:12

"Hendrik Schober" < XXXX@XXXXX.COM > writes:


Whoops. I meant to have the words "use identifiers that" inserted
before the word "start".

--
Chris (TeamB);
 
 
 

_underscrore

Post by Vinso » Fri, 25 Mar 2005 11:50:28

It will be hard to type the variables starting with underscores, especially
if you prefix all the variables with underscores to represent something.