Richard said:
You seem purposely to miss the point. I dont care if it IS an
operator. It is much neater and easier to read in its "function mode".
As I'm sure you've noticed, I rarely respond to you; I'll make an
exception for once. At least in this case you're talking about C
rather than (or in addition to) complaining about other posters.
I'm not missing your point; I'm simply disagreeing with you.
You find "sizeof n" ugly and difficult to read. That's fine;
I don't expect, or even particularly want, you to change your mind.
I find the "sizeof n" form cleaner and easier to read than the
"sizeof(n)" form. For me, *because* "sizeof" is an operator,
I prefer to treat it as one. *Because* it's not a function,
I prefer not to use a fake function-call-like syntax for it.
I could choose to uniformly apply the "sizeof" operator only to
parenthesized expressions (or, similarly, to use only parenthesized
expressions in return statements). I choose not to. Unlike you,
I do care about what's in the standard.
When I read and write C code, I tend to think of the underlying
concepts, as expressed in the language grammar and elsewhere, at
least as much as the superficial appearance. I prefer "int *ptr;"
to "int* ptr;" because the former reflects the language grammar and
semantics (*ptr is an int, rather than ptr is an int*). I don't
write "return(x);" because it's a return keyword followed by a
parenthesized expression, and the parentheses are unnecsssary.
I declare the second parameter to main as "char **argv" rather than
"char *argv[]" because the former expresses what it really is, a
pointer to pointer to char. I don't write "sizeof(n)" because it's
a sizeof keyword (operator) applied to a parenthesized expression;
the parentheses are unnecessary and provide no additional clarity
*for me*.
There's room for legitimate disagreement on all these stylistic
points, and I've never claimed otherwise. And I'm sure that a
strictly consistent application of the principle I've outlined
leads to some things that *I* would find ugly and unclear. I don't
claim to be 100% consistent (though I'd be interested in seeing
any examples; I might re-think a few things.)
Now if you prefer to write "sizeof(n)" because you happen to like it
better, that's fine with me; I have no trouble reading such code,
even if I wouldn't have written it that way myself. It doesn't
cause me to question your competence or honesty. If you want
to tell me that I should do the same, that's ok too; I'm free to
ignore your advice. If you tell me that I and everyone else who
feels as I do is being dishonest, that our reasonable coding style,
fully supported by the language standard, violates "common sense",
that it's nothing more than the "clique" being "clever", I find
that just a bit annoying.
Please note that most of what I've written here has been statements
about my own personal preferences, my own mental state. If you wish
to make a fool of yourself by disputing those statements, about which
you can have no knowledge other than what I've told you, feel free.