Topic: Reserved indentifiers


Author: warwick@cs.uq.oz.au (Warwick Allison)
Date: 5 Apr 93 05:50:18 GMT
Raw View
andrew@pest (Andrew Burow) writes:


>That may be true, but why couldn't the compiler use 4 underscores or
>even 10 for that matter. There are times when 2 underscores would be handy
>to use.

I'm sure your compiler will use "__" more often than you will, so simply
use "___" in those very rare circumstances... or is "___" counted as
a two-underscore identifier by the draft std?


--
Warwick
  _-_|\      warwick@cs.uq.oz.au            /Disclaimer:
 /     * <-- Computer Science Department,  /
 \_.-._/     University of Queensland,    /   C references are NULL && void*
      v      Brisbane, Australia.        /




Author: steve@taumet.com (Steve Clamage)
Date: Thu, 8 Apr 1993 05:25:34 GMT
Raw View
warwick@cs.uq.oz.au (Warwick Allison) writes:

>I'm sure your compiler will use "__" more often than you will, so simply
>use "___" in those very rare circumstances... or is "___" counted as
>a two-underscore identifier by the draft std?

The rule is that identifiers containing two consecutive underscores
are reserved to the implementation.  Since "a___b" contains two
consecutive underscores, it is reserved, as are "___a" and "b___".
(Q: Which month has 28 days?  A: They all do.)

Current implementations sometimes use 3 underscores as part of certain
mangled names.
--

Steve Clamage, TauMetric Corp, steve@taumet.com




Author: qbarnes@urbana.mcd.mot.com (Quentin Barnes)
Date: Tue, 30 Mar 1993 00:32:35 GMT
Raw View
In X3J16/91-0115 (23-SEP-91 draft)*, section 2.4 states:

 In addition, identifiers containing a double underscore (__)
 are reserved for use by C++ implementations and the standard
 libraries and should be avoided by users.

I read this that not only are symbols such as "__ab" reserved, but
"a__b" and "ab__".  Is this correct?

Why would the C++ spec wish to reserve patterns in the middle of
identifiers?  Other specs reserve prefix strings (ANSI C) or even
postfix strings (POSIX).  Why create a new rule for reserved
identifiers?



*) I heard there was a later draft.  Is a later one available?
   If the text in question has been altered or removed, please
   post the change.
--
Quentin Barnes
qbarnes@urbana.mcd.mot.com | ..!uiucuxc!udc!qbarnes




Author: derek@watson.ibm.com (Derek Lieber)
Date: Tue, 30 Mar 1993 12:38:43 GMT
Raw View
In article <1993Mar30.003235.10816@urbana.mcd.mot.com> qbarnes@urbana.mcd.mot.com (Quentin Barnes) writes:
>...
>I read this that not only are symbols such as "__ab" reserved, but
>"a__b" and "ab__".  Is this correct?
>
>Why would the C++ spec wish to reserve patterns in the middle of
>identifiers?
>...

Double underscores are used by some C++ compilers (ie. cfront)
in their name mangling schemes.
--
Derek Lieber
derek@watson.ibm.com




Author: steve@taumet.com (Steve Clamage)
Date: Tue, 30 Mar 1993 18:29:22 GMT
Raw View
qbarnes@urbana.mcd.mot.com (Quentin Barnes) writes:

>In X3J16/91-0115 (23-SEP-91 draft)*, section 2.4 states:

> In addition, identifiers containing a double underscore (__)
> are reserved for use by C++ implementations and the standard
> libraries and should be avoided by users.

>I read this that not only are symbols such as "__ab" reserved, but
>"a__b" and "ab__".  Is this correct?

Yes.  The restriction is also stated in the ARM.  The reason is that
current implemenations use "__" as part of "name mangling" to allow
overloaded names.  If you were allowed to use a double underbar, you
could accidentally collide with a compiler-generated name used for a
different purpose.  Disallowing double underbars seems like a rather
mild restriction in exchange for the benefits of name space protection.

>*) I heard there was a later draft.  Is a later one available?

There is a new "draft" about every 4 months.  The "draft" is really
only a working paper, not a draft standard (yet).  Parts of it are
relatively uninspected, and those parts often have errors which do
not represent the intent of the committee.  You need to follow the
committee deliberations in email and published papers to be able to
figure out what is real and what is uninspected in the working paper.

If you need to keep current on C++ committee deliberations, you should
join the committee.  Send me email and I'll send you some information
on how to join.  Anyone may do so.
--

Steve Clamage, TauMetric Corp, steve@taumet.com