The
Keyword Challenge
In a shameless trick to promote my book, I put a discussion of an exercise of Bjarne Stroustrup on my web-pages: how to write a legal C++ program with ten distinct consecutive keywords. The proposed challenge was: how to make it eleven. And once someone finds that, how to align twelve of them... you get the idea. |
Gargantua
Blargg easily modified the ten-keyword demonstration to make it eleven:
int main() {What's more, he sent in this example that aligns 20 "extended keywords" (i.e., alternative tokens for various symbolic operators): struct X { |
Impressive?
Scary? Probably, but Anatoli Tubman sent in better yet:
signed long int volatile arr[1];Note the use of the bitand token instead of the ampersand ('&') to denote the reference type. And that's 24 keywords... |
Doing
better than these is quite hard indeed. I have received a few examples
with more keywords, but though they compile on particular compilers, they
are not in fact valid ANSI C++.
If you can build a valid uninterrupted C++ sequence of twelve distinct classic keywords or 25 different extended keywords, e-mail me! |