On Apr 24, 2:14 pm, "Moschops" <mosch...@[EMAIL PROTECTED]
> wrote:
> Posted here because comp.std.c++ seems to have died an unexpected death.
>
> -------
>
> 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.
Adding a new keyword to the langauge means that you are almost
guaranteed to break someone's code. Take a look at this discussion
about var in C#:
http://www.strangelights.com/blog/archive/2005/10/10/1264.aspx
In general, adding new meanings for an existing keyword are easier to
do without breaking old code than adding new keywords. When new
keywords are added... it generally involves searching over large code
bases for instances of the symbol already being used.
The way compilers work, true keywords are detected at lexical analysis
time (when systactic information isn't present), so you can't tell if
someone *meant* to use the keyword as a variable name, even if it is
clearly placed like this:
int var;
If var is a keyword, that will fail to parse without some fairly
heroic hackery.
So that's why languages are often pretty much stuck with the keywords
they started out with, or when they add new keywords they use ugly
prefixes that users aren't supposed to use like _. For instance in C99
they added _Imaginary, _Complex, and _Bool.
A lot of the way languages change has to do with the inflexibility of
lexers and parsers to tell that this syntax means this in a certain
context, but not in another context.
--
[ See http://www.gotw.ca/resources/clcm.htm
for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


|