[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gpsd-dev] gpsd style change?

From: Gary E. Miller
Subject: Re: [gpsd-dev] gpsd style change?
Date: Tue, 10 Feb 2015 22:17:28 -0800

Yo Eric!

On Tue, 10 Feb 2015 23:44:28 -0500
"Eric S. Raymond" <address@hidden> wrote:

> Gary E. Miller <address@hidden>:

> That's odd.  I always move them as close to usage as possible, both
> because I share your preference and because cppcheck throws warnings
> if the scope of a variable can be reduced.

Good, that is the answer I like to hear.

> > Is this now an official style change?  I would prefer it that way.
> > If so can it be made official somewhere so things don't move back
> > and forth.
> We don't have an official style guide, but I am 100% behind giving
> variables scopes as narrow as possible. Go with your instinct on this.

Sadly not all people instincts agree.  Glad we agree here.  I'll save
this email the next time my code is changed the other way.

> > Or, bigger picture, maybe a real style guide?
> Be careful what you wish for.  If we had one, some of your coding
> quirks might be agin' it.  My eyeballs stumble whenever I see that "if
> (0 == foo)" thing you like to do...

Funny, as that grows on most people.  It is not a common C style, but
is sometimes used explicitlly in PHP style guides.

If it causes you to stumble and think about the code that is a good
thing.  Soon your brain knows the constant on the right is an assignment
and the constant on the left is a comparisonn.  Also putting the constant
on the left side lets the compiler find typos like "if ( foo = 0 )"
which can be really hard to spot.

Can you honestly say you never had trouble finding a logic error like
"if (foo = 0 )"?

Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97701
        address@hidden  Tel:+1(541)382-8588

reply via email to

[Prev in Thread] Current Thread [Next in Thread]