Yeah, I know why it is the way it is. I still think it's bonkers (esp. function pointers). The one somewhat beautiful part of C declaration syntax is if you have a declaration of a variable and you put
typedef before it, then the declaration remains legal and defines a typedef instead, of the same name.
I think I prefer the C++11
using foo_t = int; syntax (if that's still legal for non-template typedefs?) for C++ code because the new name is given first
1, but the C version
does have a really nice parallel syntax for the two constructs.
But I joke about the LSD thing. To be clear, I don't like C; I have a lot of problems with it and C++. But the design space was very very different in 1970, both because of far more limited machines and because we didn't know nearly as much about programming language design. And thus I think very few of C's decisions (or Unix's, which I also rag on Ritchie for sometimes) were actually bad at the time, and it was really pretty revolutionary at the time and went a long way towards advancing computing. What I really meant was "anyone who designs a language
now who follows that rule of C must be taking LSD."
1 I don't have experience with trying to read this code, but I suspect that it'd be easier. I find it hard to scan a long line like
std::vector<pair<int, int>>::const_iterator iter to jump immediately to the name of the variable being declared, especially as you start adding more template parameters (which in addition to making the type longer also adds spaces to it, so you can't even just look for the break). You have to scan backwards from the end of the line. And I find I'm much more interested in the story "I'm declaring
x to be an
int" than in "I'm declaring an
int I'm going to call
x." Just think of one of the common reasons to look at a declaration that's already written: you want to see what type something has! It's like part of the reason why I prefer
Foo const & to
const Foo & -- the
Foo is the more important part!
Obviously the new
using aliases don't help with variables, but the step in typedef world is equivalent and still forward. It's just an analog to Amdahl's law grossly limits the overall benefit.
Edit: I think I'm done mucking with this post now. :-p