The behavior of [] is from C -- it's not a bizarro C++ feature.
The "redefining keywords" is the pre-processor. That's what it does. There isn't anything magic here. Strictly speaking it can be run entirely ahead of the C/C++ compiler, on any file you want. There's no requirement that it is C/C++ - you could use it on a python script (as long as you weren't using # comments anywhere :D )
I didn't see the author use the word "bizarro" anywhere, nor make any claims about any of this stuff being weird. He actually presented almost everything in a fairly neutral tone, except when he said that using the preprocessor to override keywords was dangerous (which could be construed as opinion).
While it's definitely a rarely-used feature, the equivalence a[b] == *(a + b) == b[a] is fundamental to pointer math. Once you grok pointer math, then this is an interesting bit of syntax trivia and should not be forgotten easily.
Except you didn't have to learn it as part of learning C, you didn't have to learn C to learn C++, and I would bet 99% of C and C++ programmers have no idea that 5[p] is valid code.
Moreover, 3[a] appears to be supported solely for backwards compatibility with C since it works only for pointers - you can't do this with classes which define operator[](int).
There is somewhat of a requirement with the preprocessor - if you redefine a keyword and then include a standard library header it's considered undefined behavior. Maybe that's what the author meant.
then it would indeed just be an if condition expression that happened to be an assignment.
But the variable is being declared as well, so what's actually going on here is a declaration and an initialiser expression. There is actually new functionality here that needed a bit of language design thought, e.g., the declared variable's scope is the whole if statement, not just the condition expression.
Imagine my surprise, getting out of college and trying to use this at my job, when the compiler told me it was invalid! It wasn't obscure to me, but apparently was to the Sun Studio C++ compiler.
The noteworthy bit is that declarations are valid in the conditional "expression" of if-statements and evaluate to the declared variable. It's imo not obvious that declarations are expressions sometimes.
To be precise, declarations are never expressions - there are two forms of if and while statements in the grammar, one taking an expression and the other a declaration.
I was going to say the same thing. I guess I've been doing C++ for too long to consider these obscure. Any nontrivial C++ codebase is likely to have several of these.
Re. the "redefining keywords" trick. I know this works with at least some versions of g++. However when I tried doing it in MSVC 2008 I ended up with link errors between the library object files (compiled without the redefinition trick) and the app executable that did use the trick. It looked like MSVC was encoding the visibility in the mangled method names.
The first review I read about the StarOffice source code (now OpenOffice, LibreOffice) back then when it was open sourced was that it was full of #define private public lines
My favorite is that these are indeed "alternate operator tokens" an so you can use `compl` in place of ~ to name a destructor. Like, for explicit destruction:
I think the only thing "obscure" in this list is the "pointer-to-member" syntax. It's conceptually simple but the syntax is pretty bizarre, hard to remember even when you're searching for it, and probably a lot of C++ programmers working professionally will not recognize it.
I remember a few years ago I was writing some code where using pointer-to-struct-member made lots of sense to me. Doing a code review I was asked politely by a peer to rewrite without them. I disagreed but didn't mind doing so, if it made people on the team happier about readability.
Sorry, I know I'm drifting massively off topic now, but why on earth would any company adopt such a policy? It's not even as if CSS files can carry executable code (sure, they can reference such content, but then block that stuff instead of the style sheets themselves).
Yeah, opera is why I said mainstream. I haven't used anything other than opera in so long that I don't really know which features firefox and chrome still haven't copied yet.
Although the article's interesting (hardly new info, but concisely described), the ghetto antialiasing, - or whatever excuse the CSS-writer had in mind for gray-on-gray text - really hurts legibility. Seriously, high contrast is the answer - look at 95%+ of all books (white on black is high contrast but costs a lot more in ink, so books only typically have white on black).
Back to the content, C++ syntax has always been a bit nasty, and the try/catch for constructor initializers adds yet another wart. It makes me miss LISP again.
The "redefining keywords" is the pre-processor. That's what it does. There isn't anything magic here. Strictly speaking it can be run entirely ahead of the C/C++ compiler, on any file you want. There's no requirement that it is C/C++ - you could use it on a python script (as long as you weren't using # comments anywhere :D )