[MPlayer-cvslog] CVS: main/libmpcodecs pullup.c,1.20,1.21
D Richard Felker III
dalias at aerifal.cx
Sun Feb 6 08:17:55 CET 2005
On Sat, Feb 05, 2005 at 01:01:56AM +0100, Felix Buenemann wrote:
> On Friday 04 February 2005 17:37, D Richard Felker III wrote:
> > On Tue, Feb 01, 2005 at 08:53:14PM +0100, Alex Beregszaszi wrote:
> > > Hi,
> > >
> > > > > > Update of /cvsroot/mplayer/main/libmpcodecs
> > > > > > In directory mail:/var2/tmp/cvs-serv15342
> > > > > >
> > > > > > Modified Files:
> > > > > > pullup.c
> > > > > > Log Message:
> > > > > > adding proper parenthesing
> > > > >
> > > > > Oh, good. I've been keeping exactly the same patch in my tree for
> > > > > months, but I've never had the time to post it with proper
> > > > > explanation why it is needed. Thanks.
> > > >
> > > > it's not needed and i was going to flame alex for not knowing c order
> > > > of operations and cluttering the code (which is considered external
> > > > imported code, not mplayer-native code) for cosmetics. but it's not
> > > > worth arguing over...
> > >
> > > It's not about my knowledge but about bad compilers...
> >
> > rotfl, is there a compiler that compiles this wrong?? maybe gcc3?
> >
> > :))))
>
> It's also about clarity, 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.
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.
> And if you're to lazy for wrtiting parentheses, simply get a good editor like
> vim, that does the job for you.
It has nothing to do with laziness, it's a matter of readability.
Rich
More information about the MPlayer-cvslog
mailing list