News for hackers. Stuff that matters.
Re:ISO C is increasingly moronic by aliguori on Tuesday December 20, 2011 @08:52PM (#3376048)
If the goal is to allow the introduction of new keywords, then it's fairly simple. Don't parse anything in the form __[a-z0-9$_] as anything but a keyword.

Problem solved. Instead, they did something awkward by trying to carve out namespaces for the stdlib too but quite frequently don't adhere to their own rules.

Re:ISO C is increasingly moronic by gsg on Wednesday December 21, 2011 @02:01AM (#3376646)
The goal is not just to allow for new keywords. Reserved identifiers are also intended to be used in system headers to protect implementation code from the unfortunate effect of user defined symbols.

Go and read your /usr/include/stdio.h (or equivalent). It will be filled with such symbols. Obviously the compiler must lex them exactly as it would unreserved symbols.

This is an unfortunately legacy of C's decision to pass compilation information around by textual inclusion, and isn't really fixable at this point.

Re:ISO C is increasingly moronic by JoshTriplett on Wednesday December 21, 2011 @05:07AM (#3376979)
System headers could use a #pragma _SystemIdentifiers, much like TeX's "makeatletter" and "makeatother" that allow packages to use @ in the name of internal symbols to avoid conflicts.

I do think compilers ought to have warnings for using identifiers in the reserved namespace. Most projects probably wouldn't trip over the ^_[A-Z] reserved space; however, numerous projects would trip over the reservation of any identifier containing two adjacent underscores.

Re:ISO C is increasingly moronic by gsg on Wednesday December 21, 2011 @07:44AM (#3377318)
That would require changing every single existing header that currently contains reserved identifiers. Do you have any idea how much work that is? Even if you could somehow magically enumerate and alter them all - and test them, since the necessary renaming of identifiers in non-system headers might introduce a bug - legacy versions would be floating around for years.

Conceptually a warning is a nice idea, but it just isn't practical.

Re:ISO C is increasingly moronic by JoshTriplett on Wednesday December 21, 2011 @01:36PM (#3378527)
Not necessarily. GCC, at least, avoids showing warnings in system headers unless explicitly requested. So, normally you'd only see warnings about the use of reserved identifiers in your own code.
Re:ISO C is increasingly moronic by TheNewAndy on Wednesday December 21, 2011 @02:04AM (#3376660)
But there are lots of places where these identifiers aren't keywords, and it is valid code (try writing a compliant stdlib without using them).

The problem is that too many people assume that their usage of C is the same as everyone elses. I don't want to be writing a system library and fighting my compiler everytime I put something in the symbol table that isn't in the C spec.

Re:ISO C is increasingly moronic by to3m on Tuesday December 20, 2011 @09:53PM (#3376188)
It's to allow use of any identifiers anywhere, not just keywords, without having to worry about conflicts with the including code.