[bind10-dev] a bikeshed style question: parenthesize return values?

Shane Kerr shane at isc.org
Wed Jun 23 11:35:16 UTC 2010


Jinmei,

On Tue, 2010-06-22 at 11:37 -0700, JINMEI Tatuya / 神明達哉 wrote:
> I've noticed we are not consistent on whether or not to parenthesize
> return values in our C++ code.  We have both:
> 
>     return (val);
> and
>     return val;

<snip/>

> Is there any comment on this, especially if it's more than a mere
> preference?

In general I believe in lots and lots of parentheses. I find this sort
of thing scary:

    if (foo == bar && baz == qux) {

I end up googling for operator precedence every time, and so always
write things thusly:

    if ((foo == bar) && (baz == qux)) {

But in the case of return, I don't get confused and tend to leave off
the parentheses when doing my own code.

One possible justification for this beyond simple preference is that
putting parentheses around return values makes it look more like a
function and sticks out a bit less:

        quux(1);
        return (7);
    }

Of course with syntax highlighting editors - plus the extra space after
the "return" keyword before the opening parenthesis - this is not that
big of a deal, but it is something.

--
Shane




More information about the bind10-dev mailing list