Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: The reuse o...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 14 of 15 Topic 9542 of 9830
Post > Topic >>

Re: The reuse of keywords in the C++ standard

by catphive <catphive@[EMAIL PROTECTED] > Apr 26, 2008 at 03:33 AM

On Apr 25, 3:13 pm, nickf3 <nic...@[EMAIL PROTECTED]
> wrote:
> On Apr 25, 12:47 pm, "Moschops" <mosch...@[EMAIL PROTECTED]
> wrote:
>
> > >> I note with some dismay the proposal to create a new meaning for
the C
> > >> and C++ keyword 'auto', as described in the do***ent N1984 (part of
the
> > >> proposals for C++0X or whatever it's called now). Efforts are being
taken to
> > >> ensure it doesn't conflict with the previous meaning of the
keyword, but why
> > >> not simply have a whole new keyword? These guys aren't stupid, so I
> > >> assume there must be a good reason.
>
> > > Yeah, nobody used auto (it was a storage class specifier that
specified
> > > automatic storage, and since local variables are automatic by
default,
> > > and you can't use it elsewhere, what's the point?), and so it was
> > > reused, to avoid adding new keywords.  If you add new keywords, you
risk
> > > breaking existing code.
>
> > Perhaps next language we should have a symbol that identifies
keywords, to
> > save us having to overload already existing keywords. Some kind of
prefix
> > that's illegal to use unless it is prefixing a recognised keyword.
>
> > 'Chops
>
> Which is again would be a keyword? I would hate to implement such
> grammar :)

He said a prefix. C99, and also compiler writers already do this by
prefixing extensions with _ or __. Like _Complex. While the compiler
will not stop you from using _ or __ prefixes in your code, they are
reserved for implementation by convention (it's in the standard
somewhere I think).

Thus, there is a way to add new keywords to C and C++ without breaking
anything... but they are ugly keywords because they all start with _.
Thus, the standards committee has chosen to risk breaking code by
adding new keywords without underscores a number of times.

I think a better idea than designing a language with a prefix for
keywords, is designing a language with a prefix for variables. Many
languages use sigils such as $, @[EMAIL PROTECTED]
 @[EMAIL PROTECTED]
 to prefix variables and
disambiguate scope. Additonally, ruby uses upper an upper case first
letter to identify constants and types. If you made this universal,
you could have a grammar with a syntax that could be arbitrarily
extended without risking breaking old code. You could also use
keywords for variable names, because the lexer would be able to tell
the difference with a simple regular expression. You could have the
keyword auto and the variable $auto.

Unfortunately, neither C++ nor any other language I know of has taken
that path, and thus extending the syntax becomes painful.

Brendan Miller

-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 15 Posts in Topic:
The reuse of keywords in the C++ standard
"Moschops" <  2008-04-24 15:14:37 
Re: The reuse of keywords in the C++ standard
red floyd <no.spam@[EM  2008-04-25 03:44:16 
Re: The reuse of keywords in the C++ standard
"Bob" <nospa  2008-04-25 03:47:59 
Re: The reuse of keywords in the C++ standard
Peter Jones <dev-null@  2008-04-25 04:13:19 
Re: The reuse of keywords in the C++ standard
"Ivan Vecerina"  2008-04-25 04:13:19 
Re: The reuse of keywords in the C++ standard
Marco Manfredini <ok_n  2008-04-25 10:14:56 
Re: The reuse of keywords in the C++ standard
Brendan <catphive@[EMA  2008-04-25 10:15:41 
Re: The reuse of keywords in the C++ standard
Alberto Ganesh Barbati &l  2008-04-25 10:49:46 
Re: The reuse of keywords in the C++ standard
"Moschops" <  2008-04-25 10:47:58 
Re: The reuse of keywords in the C++ standard
Pete Becker <pete@[EMA  2008-04-25 11:13:19 
Re: The reuse of keywords in the C++ standard
Ron Natalie <ron@[EMAI  2008-04-25 15:39:59 
Re: The reuse of keywords in the C++ standard
Andre Kaufmann <akfmne  2008-04-25 16:16:26 
Re: The reuse of keywords in the C++ standard
nickf3 <nickf3@[EMAIL   2008-04-25 16:13:19 
Re: The reuse of keywords in the C++ standard
catphive <catphive@[EM  2008-04-26 03:33:13 
Re: The reuse of keywords in the C++ standard
marlow.andrew@[EMAIL PROT  2008-04-26 08:41:52 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 15:36:31 CDT 2008.