[FFmpeg-cvslog] r10500 - trunk/libavcodec/vc1.c
The Wanderer
inverseparadox
Tue Sep 18 04:23:39 CEST 2007
Michael Niedermayer wrote:
> Hi
>
> On Mon, Sep 17, 2007 at 02:01:24PM -0700, Mike Melanson wrote:
>
>> The Wanderer wrote:
[inner parentheses in "((mquant == v->pq) ? v->halfpq : 0)"]
>>> They may not be necessary semantically, but I for one do not know
>>> operator precedence well enough to be able to tell at a glance
>>> whether the version without them would perform the ternary
>>> conditional before or after the equality comparison. The addition
>>> of the parentheses makes it plain, and does not hurt readability
>>> in the aesthetic sense IMO.
>> Thanks for articulating this better than I could. Aside from "*/+-"
>> I can never remember operator precedence rules (which I think
>> change subtly between different languages). That's why I like
>> parens around ops that deviate from the 4 basic math operators.
>
> so you plan to write: a = (b + (c[5]));
>
> instead of
>
> a = b + c[5];
>
> as that could be
>
> ((a = b) + c)[5];
>
> ?
>
> ;)
For that matter, it could be
a = ((b + c)[5]);
which would be more likely, since having an array-reference statement
which does nothing with the referenced value doesn't make a whole lot of
sense. (The only thing I can think of you could do with it is test for
out-of-bounds values by triggering a segmentation fault, which does not
seem particularly useful. Then again, you could also disguise a simple
assignment that way in obfuscated code...)
Of course, no one was suggesting this, and no one sane would suggest it.
I think that Mike Melanson was simply not thinking of [] as an operator;
I'll admit that I do not think of it as one myself in ordinary activity.
I do (I believe) think of = as an operator, the assignment operator, but
because it is familiar from mathematics and it has a very distinct
purpose unlike that of any other operator I can think of, it is both
easy to remember that it has absolute top precedence - or at least, I
can't think of anything except parentheses and presumably curly braces
which override it - and easy to forget that it is in fact an operator.
--
The Wanderer is aware that you were joking, yes
Warning: Simply because I argue an issue does not mean I agree with any
side of it.
Secrecy is the beginning of tyranny.
More information about the ffmpeg-cvslog
mailing list