M
Marcus Kwok
Ben Pope said:I was supposed to say there is a bias towards describing types, rather
than variables.
I'm not sure who said it, and it is of course personal preference. Both
are equally valid.
From what I've seen, Bjarne Stroustrup prefers the former (FWIW).
Agreed, see http://www.research.att.com/~bs/bs_faq2.html#whitespace
The choice between "int* p;" and "int *p;" is not about right and
wrong, but about style and emphasis. C emphasized expressions;
declarations were often considered little more than a necessary evil.
C++, on the other hand, has a heavy emphasis on types.
A "typical C programmer" writes "int *p;" and explains it "*p is what
is the int" emphasizing syntax, and may point to the C (and C++)
declaration grammar to argue for the correctness of the style.
Indeed, the * binds to the name p in the grammar.
A "typical C++ programmer" writes "int* p;" and explains it "p is a
pointer to an int" emphasizing type. Indeed the type of p is int*.
I clearly prefer that emphasis and see it as important for using the
more advanced parts of C++ well.
...
Whenever something can be done in two ways, someone will be confused.
Whenever something is a matter of taste, discussions can drag on
forever.