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

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sun Feb 6 20:52:48 CET 2005


Hi,
On Sun, Feb 06, 2005 at 12:49:35PM -0500, The Wanderer wrote:
> 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 think you are mixing two things here: putting all in one line, which
IMHO is bad because especially after a few changes it will make the line
longer that 80 characters and also because it makes cvs diff much more
difficult to understand.
But adding unneeded braces is not any better, it takes up much too much
spaces - given the fact that I usually can only see 25 to 50 lines of
code at once I find it _very_ annonying when more than 10 consist only
of braces. Also, if you have so many nesting levels it's really hard to
see which closing brace belongs to which opening one.
That's almost like making a sub-function consisting of only 2 lines -
there are case where this is a good idea, but they are _very_ rare.

Greetings,
Reimar Döffinger




More information about the MPlayer-cvslog mailing list