The least used keywords in C++, which do you use?

Discussion in 'C++' started by Alf P. Steinbach, Sep 17, 2007.

  1. Here's the list of keywords and reserved words (the difference in C++
    escapes me!) that I don't use:

    export, auto, register, and, and_eq, or, or_eq, xor, xor_eq, not,
    not_eq, bitand, bitor, compl

    How about you?

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
     
    Alf P. Steinbach, Sep 17, 2007
    #1
    1. Advertising

  2. Alf P. Steinbach wrote:
    > Here's the list of keywords and reserved words (the difference in C++
    > escapes me!) that I don't use:
    >
    > export, auto, register, and, and_eq, or, or_eq, xor, xor_eq, not,
    > not_eq, bitand, bitor, compl
    >
    > How about you?


    'auto' may get a new (extended) meaning soon. I may start using it.

    'register' is definitely one we could simply get rid of. I never use it.

    'export'? It's a kind of "if it were there, I might use it" keyword.
    Most modern (widely available) compilers have either no, or very
    rudimentary, support for it. I bet you some library implementors would
    actually use it had it been better supported by the compilers.

    I don't use the operators ('and', 'or', etc.) mostly because those are
    less readable than symbols ('&&', '||'), and readability is one of the
    cornerstones of maintainability of the code when a larger team is
    concerned.

    I don't recall the last time I used 'goto'. Nor can I recall needing
    'friend' lately.

    Because of the nature of the algorithms I'm involved with, 'short' and
    'float' are not in my vocabulary either.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Sep 17, 2007
    #2
    1. Advertising

  3. * Victor Bazarov:
    >
    > Because of the nature of the algorithms I'm involved with, 'short' and
    > 'float' are not in my vocabulary either.


    Thanks, I forgot those! :)

    Cheers,

    - Alf

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
     
    Alf P. Steinbach, Sep 17, 2007
    #3
  4. Alf P. Steinbach

    Daniel T. Guest

    "Alf P. Steinbach" <> wrote:

    > Here's the list of keywords and reserved words (the difference in C++
    > escapes me!) that I don't use:
    >
    > export, auto, register, and, and_eq, or, or_eq, xor, xor_eq, not,
    > not_eq, bitand, bitor, compl
    >
    > How about you?


    I have been programming in C/C++ for going on 10 years and I have never
    used 'continue', I only use 'break' inside a switch statement. Lastly, I
    have never used 'goto'.
     
    Daniel T., Sep 17, 2007
    #4
  5. Alf P. Steinbach

    duane hebert Guest

    "Victor Bazarov" <> wrote in message
    news:fcm8d3$vgd$...
    > Alf P. Steinbach wrote:
    >> Here's the list of keywords and reserved words (the difference in C++
    >> escapes me!) that I don't use:
    >>
    >> export, auto, register, and, and_eq, or, or_eq, xor, xor_eq, not,
    >> not_eq, bitand, bitor, compl
    >>
    >> How about you?

    >
    > 'auto' may get a new (extended) meaning soon. I may start using it.
    >
    > 'register' is definitely one we could simply get rid of. I never use it.
    > I don't recall the last time I used 'goto'. Nor can I recall needing
    > 'friend' lately.


    I haven't used register in C++ but I probably have some old C
    stuff around still using it. Our "coding standard" doesn't allow
    goto (for historical reasons - don't ask.) I have friend in a couple
    of modules but a pending refactor will probably change that.


    > Because of the nature of the algorithms I'm involved with, 'short' and
    > 'float' are not in my vocabulary either.


    I do a lot of I/O stuff so short is still around but not float. The rest,
    I don't use.
     
    duane hebert, Sep 17, 2007
    #5
  6. Alf P. Steinbach

    Puppet_Sock Guest

    On Sep 17, 11:42 am, "Alf P. Steinbach" <> wrote:
    > Here's the list of keywords and reserved words (the difference in C++
    > escapes me!) that I don't use:
    >
    > export, auto, register, and, and_eq, or, or_eq, xor, xor_eq, not,
    > not_eq, bitand, bitor, compl
    >
    > How about you?


    I don't use any of those. There are quite a few that
    I don't usually bother with, or don't use often.

    volatile is also one that I've had little cause to
    use. I would *not* want to see it removed from the
    lang. I just don't happen to write stuff where
    volatile would apply.

    I think there's probbaly a lot of portions of the lang
    that specific people rarely, or never, use. But the
    lang is a multi-paradigm language. You don't need all
    the bits-and-bobs. Until the day you *do* need one of
    them, and then it's there. One day I will write a code
    that gets used on a real-time-hardware system that does
    change the value of variables, and volatile will be
    pretty important. Or, one day, I will be using a non-
    English keyboard or something, and the & key won't
    be they & character.
    Socks
     
    Puppet_Sock, Sep 17, 2007
    #6
  7. Alf P. Steinbach

    Bo Persson Guest

    Daniel T. wrote:
    :: "Alf P. Steinbach" <> wrote:
    ::
    ::: Here's the list of keywords and reserved words (the difference in
    ::: C++ escapes me!) that I don't use:
    :::
    ::: export, auto, register, and, and_eq, or, or_eq, xor, xor_eq,
    ::: not, not_eq, bitand, bitor, compl
    :::
    ::: How about you?
    ::
    :: I have been programming in C/C++ for going on 10 years and I have
    :: never used 'continue', I only use 'break' inside a switch
    :: statement. Lastly, I have never used 'goto'.

    Also asm is about as useful as goto. I don't find much practical use
    for signed either (signed char, anyone?).

    Might have used typeid and volatile about once each. .-)


    Perhaps we could create a new, smaller language?


    Bo Persson
     
    Bo Persson, Sep 17, 2007
    #7
  8. Alf P. Steinbach

    red floyd Guest

    Bo Persson wrote:
    > Daniel T. wrote:
    > :: "Alf P. Steinbach" <> wrote:
    > ::
    > ::: Here's the list of keywords and reserved words (the difference in
    > ::: C++ escapes me!) that I don't use:
    > :::
    > ::: export, auto, register, and, and_eq, or, or_eq, xor, xor_eq,
    > ::: not, not_eq, bitand, bitor, compl
    > :::
    > ::: How about you?
    > ::
    > :: I have been programming in C/C++ for going on 10 years and I have
    > :: never used 'continue', I only use 'break' inside a switch
    > :: statement. Lastly, I have never used 'goto'.
    >
    > Also asm is about as useful as goto. I don't find much practical use
    > for signed either (signed char, anyone?).
    >
    > Might have used typeid and volatile about once each. .-)
    >
    >

    Us bit-twiddlers use volatile a lot for registers.

    We even use const volatile for read-only registers.
     
    red floyd, Sep 17, 2007
    #8
  9. Bo Persson wrote:
    > Daniel T. wrote:
    >>> "Alf P. Steinbach" <> wrote:
    >>>
    >>>> Here's the list of keywords and reserved words (the difference in
    >>>> C++ escapes me!) that I don't use:
    >>>>
    >>>> export, auto, register, and, and_eq, or, or_eq, xor, xor_eq,
    >>>> not, not_eq, bitand, bitor, compl
    >>>>
    >>>> How about you?
    >>>
    >>> I have been programming in C/C++ for going on 10 years and I have
    >>> never used 'continue', I only use 'break' inside a switch
    >>> statement. Lastly, I have never used 'goto'.

    >
    > Also asm is about as useful as goto.


    I'd argue with that, but not today.

    > I don't find much practical use
    > for signed either (signed char, anyone?).


    It seems that on all platforms I've been in, char was signed by default;
    although, of course, char and signed char are different types... But
    you're right, the keyword 'signed' is something I probably have never
    used, except in an explicit template instantiation for 'signed char'.

    > Might have used typeid and volatile about once each. .-)


    'volatile' for me was always the solution to work around some weird
    optimizer bugs when the code forgets to update the memory location
    of the variable. I think I've only encountered it in Visual C++,
    however.

    > Perhaps we could create a new, smaller language?


    :) Wasn't there already C-- for that?

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Sep 17, 2007
    #9
  10. Alf P. Steinbach

    Puppet_Sock Guest

    On Sep 17, 12:01 pm, "Victor Bazarov" <> wrote:
    [snip]
    > I don't recall the last time I used 'goto'.


    The last time I used 'goto' was about 1992 or so. The client
    changed the spec long after I had started the coding stage.
    Indeed, I was in the last throws of testing.

    And suddenly, there's a new requirement that was not easy
    to accomodate. Sigh.

    I did learn to make some changes to my coding style such
    that "that sort" of change was easier to accomodate.
    But at the time, I would have either had to have rewritten
    substantial code and missed the deadline, or insert one
    'goto' statement. And make the deadline.

    I agree that 'goto' is not something to reach for
    in the usual case, or even the mildly unusual case.
    Once in 15 years, and counting. But I'd be unhappy to
    have it removed from the language.

    I also put that section of code on my "if you change
    this code for other reasons, think about cleaning
    up this while you are there" list. And, no surprise,
    the client changed the spec again requiring that
    section to be fairly extensively rewritten. And I
    got rid of the 'goto' then.
    Socks
     
    Puppet_Sock, Sep 17, 2007
    #10
  11. Victor Bazarov wrote:
    > Alf P. Steinbach wrote:
    >> Here's the list of keywords and reserved words (the difference in C++
    >> escapes me!) that I don't use:
    >>
    >> export, auto, register, and, and_eq, or, or_eq, xor, xor_eq, not,
    >> not_eq, bitand, bitor, compl
    >>
    >> How about you?

    >
    > 'auto' may get a new (extended) meaning soon. I may start using it.


    The only time I use it is to show how to use it.

    >
    > 'register' is definitely one we could simply get rid of. I never use it.


    If an object is a "register", then you can't take the address of it
    which means that the compiler is allowed to assume that it is not
    aliased which (in theory) would allow for certain optimizations that it
    would otherwise not.
     
    Gianni Mariani, Sep 17, 2007
    #11
  12. Victor Bazarov wrote:
    > Alf P. Steinbach wrote:
    >> Here's the list of keywords and reserved words (the difference in C++
    >> escapes me!) that I don't use:
    >>
    >> export, auto, register, and, and_eq, or, or_eq, xor, xor_eq, not,
    >> not_eq, bitand, bitor, compl
    >>
    >> How about you?


    asm ?
     
    Gianni Mariani, Sep 17, 2007
    #12
  13. Alf P. Steinbach

    Pete Becker Guest

    On 2007-09-17 17:22:23 -0400, Gianni Mariani <> said:

    >
    > If an object is a "register", then you can't take the address of it
    > which means that the compiler is allowed to assume that it is not
    > aliased which (in theory) would allow for certain optimizations that it
    > would otherwise not.


    That's true in C, but it's different in C++. [dcl.stc]/2-3:

    The register specifier shall be applied only to names of objects declared in a
    block (6.3) or to function parameters (8.4). It specifies that the
    named object
    has automatic storage duration (3.7.2). An object declared without a
    storage-class-specifier at block scope or declared as a function parameter has
    automatic storage duration by default.

    A register specifier is a hint to the implementation that the object
    so declared will
    be heavily used. [ Note: the hint can be ignored and in most
    implementations it
    will be ignored if the address of the object is taken. — end note ]

    --
    Pete
    Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
    Standard C++ Library Extensions: a Tutorial and Reference
    (www.petebecker.com/tr1book)
     
    Pete Becker, Sep 18, 2007
    #13
  14. Alf P. Steinbach

    James Kanze Guest

    On Sep 17, 6:01 pm, "Victor Bazarov" <> wrote:
    > Alf P. Steinbach wrote:
    > > Here's the list of keywords and reserved words (the difference in C++
    > > escapes me!) that I don't use:


    > > export, auto, register, and, and_eq, or, or_eq, xor, xor_eq, not,
    > > not_eq, bitand, bitor, compl


    > > How about you?


    It obviously depends on the application domain. Where I worked
    before, I didn't use float or double. I've never used wchar_t
    either, in an actual application. Unless you're doing very low
    level programming, reinterpret_cast probably remains unused as
    well.

    And of course, I've never used continue or goto, in over 25
    years of C/C++. And when I encounter it in code I have to work
    on, I simply throw the code out and start over.

    > 'auto' may get a new (extended) meaning soon. I may start
    > using it.


    > 'register' is definitely one we could simply get rid of. I
    > never use it.


    > 'export'? It's a kind of "if it were there, I might use it" keyword.


    I would definitly use it. It would solve no end of problems.

    > Most modern (widely available) compilers have either no, or
    > very rudimentary, support for it. I bet you some library
    > implementors would actually use it had it been better
    > supported by the compilers.


    > I don't use the operators ('and', 'or', etc.) mostly because
    > those are less readable than symbols ('&&', '||'), and
    > readability is one of the cornerstones of maintainability of
    > the code when a larger team is concerned.


    In this case, readability is in the eyes of the beholder. I'm
    more used to && and || as well, but other people I know find and
    and or more explicit.

    > I don't recall the last time I used 'goto'. Nor can I recall needing
    > 'friend' lately.


    > Because of the nature of the algorithms I'm involved with,
    > 'short' and 'float' are not in my vocabulary either.


    I'm surprised that Alf didn't mention wchar_t. If I need
    Unicode, I'll use uint32_t, given that wchar_t isn't guaranteed
    to suffice (and doesn't on some common platforms). Except that
    even more often, I'll use UTF-8, which means that char is fine.

    I also notice that "asm" is in the official list of keywords. I
    certainly wouldn't recommend it in portable code, however:).

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, Sep 18, 2007
    #14
  15. Alf P. Steinbach

    James Kanze Guest

    On Sep 17, 8:34 pm, "Bo Persson" <> wrote:
    > Daniel T. wrote:


    > :: "Alf P. Steinbach" <> wrote:


    > ::: Here's the list of keywords and reserved words (the difference in
    > ::: C++ escapes me!) that I don't use:


    > ::: export, auto, register, and, and_eq, or, or_eq, xor, xor_eq,
    > ::: not, not_eq, bitand, bitor, compl


    > ::: How about you?


    > :: I have been programming in C/C++ for going on 10 years and I have
    > :: never used 'continue', I only use 'break' inside a switch
    > :: statement. Lastly, I have never used 'goto'.


    > Also asm is about as useful as goto.


    It depends on what level you're programming on. I tend to
    prefer separate modules, written in assembler, to asm, but I do
    use assembler for certain very low level threading primitives
    (atomic increment, etc.), on some machines.

    > I don't find much practical use
    > for signed either (signed char, anyone?).


    > Might have used typeid and volatile about once each. .-)


    I don't use volatile today, but I worked on embedded systems in
    the past, and it found use there. And typeid pops up a lot in
    experiments and demo programs (although it is practically unused
    in applications).

    --
    James Kanze (GABI Software) email:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, Sep 18, 2007
    #15
  16. * James Kanze:
    >
    > I'm surprised that Alf didn't mention wchar_t. If I need
    > Unicode, I'll use uint32_t, given that wchar_t isn't guaranteed
    > to suffice (and doesn't on some common platforms). Except that
    > even more often, I'll use UTF-8, which means that char is fine.


    I actually use wchar_t and have used wchar_t a lot. :)

    It plays about the same rôle as int, the platform's "natural" wide
    character type.

    And it has the same problems: some things are more portable with wchar_t
    (such as std::wstring for holding platform-specific wide character
    strings), and some things are less portable with wchar_t (such as code
    that assumes a specific encoding, or other size-dependent assumption).

    And the same issues seem to hold for plain char.

    On a platform with 16-bit char I imagine one wouldn't use std::string
    for holding a narrow character string. However, I haven't coded for
    such a platform.

    Cheers,

    - Alf

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is it such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
     
    Alf P. Steinbach, Sep 18, 2007
    #16
  17. Alf P. Steinbach wrote:
    > Here's the list of keywords and reserved words (the difference in C++
    > escapes me!) that I don't use:
    >
    > export, auto, register, and, and_eq, or, or_eq, xor, xor_eq, not,
    > not_eq, bitand, bitor, compl


    How about 'signed'?
     
    Juha Nieminen, Sep 18, 2007
    #17
  18. Alf P. Steinbach

    mathieu Guest

    On Sep 18, 12:27 pm, Juha Nieminen <> wrote:
    > Alf P. Steinbach wrote:
    > > Here's the list of keywords and reserved words (the difference in C++
    > > escapes me!) that I don't use:

    >
    > > export, auto, register, and, and_eq, or, or_eq, xor, xor_eq, not,
    > > not_eq, bitand, bitor, compl

    >
    > How about 'signed'?



    How about virtual for class inheritance

    -Mathieu
     
    mathieu, Sep 18, 2007
    #18
  19. Alf P. Steinbach

    Ron Natalie Guest

    I haven't used goto in decades.
     
    Ron Natalie, Sep 18, 2007
    #19
  20. Alf P. Steinbach

    GameboyHippo Guest

    On Sep 18, 7:06 am, Ron Natalie <> wrote:
    > I haven't used goto in decades.


    goto first_half_of_sent;

    second_half_of_sent:
    goto all the time, I love it!

    first_half_of_sent:
    I use
    goto second_half_of_sent;
     
    GameboyHippo, Sep 18, 2007
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thirumalai
    Replies:
    2
    Views:
    430
    Joanna Carter [TeamB]
    Jun 22, 2006
  2. Sean 'Shaleh' Perry

    Re: Least used builtins?

    Sean 'Shaleh' Perry, Jul 4, 2003, in forum: Python
    Replies:
    2
    Views:
    332
    Lulu of the Lotus-Eaters
    Jul 5, 2003
  3. kkk
    Replies:
    0
    Views:
    306
  4. AAaron123
    Replies:
    0
    Views:
    596
    AAaron123
    Oct 3, 2008
  5. Aston J.
    Replies:
    13
    Views:
    619
    Justin Collins
    Mar 16, 2011
Loading...

Share This Page