|It's simply a matter of what makes it easier to read and what people are more logically to interpret it does.|
These are good words.
int* a, b;
confuses readers of the code as I was convinced many times.
So what do apologists of this style say? They agree
that it is a bad style so they suggest to write each declaration in a separate line.
But why should we write each declaration in a separate line because they select a bad style
?! I do not understand this. It is their problem
Moreover if you deal with big projects you know that very often it is not important what type has a single variable. It is important how variables are connected with each other
. For example let assume that there are declarations
If they are in different lines I need to check that they are have the same base type. It is not a problem if there are only two such declarations. But let assume that there are many queues, for example
So then I am investigating some snip of code I do not know what is the connection between variables. I should always return to their declarations and consider all lines
where for example AnotherQueue anode; and AnotherQueue *panode; are present. The worst that the two declarations can be in separate screens
. It is very inconvenient. But if these two declarations would be on the same line it makes reading of code easy.
SomeQueue node, *pnode;
AnotherQueue anode, *panode;
OneMoreQueue onode, *ponode;
I would know that each two variables are connected with each other.
Do not forget that sometimes declarations occupy more than 20 or even 30 and more lines in C. I do not want scroll screens that to find out that onode and ponode have the same base type.
And at last what about declarations of function pointers?!:) How do the apologists declare them? Of course they declare them as
int ( *f )( int, int );
Even this contradicts their style because there is not such construction as int*
in this declaration
Here int is a type specifier and ( *f )( int, int ) is a declarator. The same valid for declaration
Here int is a type specifier and *p is a declarator.
So they use a bad style and try to invent some restrictions as to write each declarations in a separate line that their style will look more or less acceptable.:)