Thread: Leading Underscores

  1. #16
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    which makes it perfectly clear that an underscore followed by an upper case letter is reserved in each and every situation, regardless of scope
    err... the C++ standard makes that pretty clear too.
    "... or begins with an underscore followed by an uppercase letter (2.11) is reserved to the implementation for any use."

    the debate is completely about interpretation and theory because all of us avoid leading underscores in our code
    Yeah, but I had to ask because I dont want to go around claiming the wrong thing.

    It's too bad we can't grab the person who wrote that rule and ask what was really meant just for peace of mind.
    Well, if we can find out from the committee(s) involved...
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #17
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >err... the C++ standard makes that pretty clear too.
    >"... or begins with an underscore followed by an uppercase letter (2.11) is reserved to the implementation for any use."
    *sigh*
    My best code is written with the delete key.

  3. #18
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    It's too bad we can't grab the person who wrote that rule and ask what was really meant just for peace of mind.
    The important thing is not what they meant. You can write code based on "what they meant" all you like. If it's not compatible with most compilers, you're not going to get very far.

  4. #19
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    Quote Originally Posted by sean_mackrory
    The important thing is not what they meant. You can write code based on "what they meant" all you like. If it's not compatible with most compilers, you're not going to get very far.
    Don't you think this is an irrelevant point since the conversation is strictly theoretical? We've already established that the guideline for good practice is to always avoid leading underscores, and we all follow that guideline. You seem to have misunderstood and thought that I actually push the limits of the standard.

    I'm sorry to say that I'm rather boring, I work in a comfortably safe subset of the language at any given time.
    My best code is written with the delete key.

  5. #20
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    hmm... this is like nearly a year ago, and now it seems that there's an article on Programming Style, Naming Conventions that touches on this by stating:
    Finally, a common convention is to prefix the private fields and methods of a class with an underscore: e.g., _private_data.
    Perhaps it might be a good idea for the article to warn about the pitfalls of using an underscore prefix, or maybe just suggest using the other convention of an underscore suffix?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. compare function ignoring leading white space
    By mc72 in forum C Programming
    Replies: 5
    Last Post: 11-23-2008, 01:33 PM
  2. leading zero's..... ( reading int )
    By sh4k3 in forum C Programming
    Replies: 4
    Last Post: 06-12-2007, 09:03 AM
  3. Removing Leading & Trailing Whitespace
    By EvilGuru in forum C Programming
    Replies: 11
    Last Post: 12-01-2005, 02:59 PM
  4. Converting underscores into spaces?
    By Cactus in forum C Programming
    Replies: 3
    Last Post: 09-24-2005, 12:34 PM
  5. Underscores
    By Hunter2 in forum C++ Programming
    Replies: 19
    Last Post: 09-12-2004, 03:31 PM