[MPlayer-cvslog] CVS: main/libmpcodecs pullup.c,1.20,1.21

The Wanderer inverseparadox at comcast.net
Sun Feb 6 18:49:35 CET 2005


D Richard Felker III wrote:

> On Sat, Feb 05, 2005 at 01:01:56AM +0100, Felix Buenemann wrote:

>> a few parentheses too much never hurt readability of code or
>> mathematial formulas aswell. If in doubt, use em :-)
>> 
>> It's a bit like:
>> 
>> if(x) for(;x<y;x++) if(x%2) do_some_thing(x);
>> 
>> versus:
>> 
>> if(x) {
>>   for(;x < y; x++) {
>>     if(x%2) {
>>       do_some_thing(x);
>>     }
>>   }
>> }
>> 
>> Both are syntactically correct, but the first version is surely
>> more error-prone when changing code and less readable.
> 
> I disagree STRONGLY! The first version is much more readable to me,
> for two reasons:
> 
> 1. it doesn't clutter the surrounding code with lots of useless
>    lines and needlessly separate what comes before and after by lots
 >    of distance.
> 2. it's a lot more internally readable.

Well, FWIW, I find the second option to be - while, yes, more cluttered
in some sense - also more readable; it's simply that when everything is
all on one line as it is in the first example, it's noticeably harder
(i.e. requires more concentration) to tell where statements begin and
end, and in the case of nested parentheses to tell which close matches
with which open. Breaking it off into multiple lines allows the
statements to be separated out visually, which makes it considerably
easier to tell at a glance what is part of something else and what is
separate. It does, as I said, mean more clutter in one sense, but it's
less dense and contains more 'signposts' (an obscure reference if ever
I've made one), so I think it comes out at worst equal in the end.

> I would be VERY pissed to find code like the second example you wrote
> above. Unneeded braces are one of my biggest pet peeves in C coding
> style.

I don't know if I'd say "pissed", but I'd very likely be less happy to
find code written in the style of the first example than the second; at
the very least, I'd be less likely to think it worth the effort to try
to read it and figure out what it does, because it *does* take me more
effort.

-- 
       The Wanderer

Warning: Simply because I argue an issue does not mean I agree with any
side of it.

A government exists to serve its citizens, not to control them.




More information about the MPlayer-cvslog mailing list