Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Mar 2006 16:40:01 +0000 (GMT)
From:      Robert Watson <rwatson@FreeBSD.org>
To:        Dmitry Pryanishnikov <dmitry@atlantis.dp.ua>
Cc:        freebsd-current@freebsd.org
Subject:   Re: style(9) question
Message-ID:  <20060302163633.H77029@fledge.watson.org>
In-Reply-To: <20060302105229.P83093@atlantis.atlantis.dp.ua>
References:  <20060302105229.P83093@atlantis.atlantis.dp.ua>

next in thread | previous in thread | raw e-mail | index | archive | help

On Thu, 2 Mar 2006, Dmitry Pryanishnikov wrote:

>  I apologize for asking here my question (it should belong to -questions, 
> but the most developers are available here, and I just hope it won't hurt). 
> What's the historical reason of the following style(9) advise:
>
> 	Values in return statements should be enclosed in parentheses.
>
> What's the rationale of this? From time to time I see small commits just 
> changing "return foo;" -> "return (foo);". I think the first form is quite 
> natural and not ambiguous. Shouldn't we remove this advise from style(9)?

Usually, these changes are a precursor to a larger semantic rewrite of code, 
where the new code being written conforms more to style(9) than the old code. 
This breaks out the style changes from the semantic changes.  You generally 
won't see style changes for the sake of style changes (although there are some 
exceptions: for example, license formatting to make it mechanically parseable, 
or changing the C prototype style so that more type checking can be 
performed).

Regarding the contents of style(9) -- generally, we try hard not to change the 
style guide, as style proves to be a rather contentious topic, as it is 
typically guided much more by opinion and taste than function.  Often, 
ambiguities in the style guide are resolved by looking at what "most" cases in 
the kernel tree currently do, then documenting that as the right way to do it. 
I can't really think of a good reason for return (foo) over return foo, but 
changing it will just make a bunch of code that previously conformed to the 
style guide cease to do so, which probably doesn't really improve matters :-).

Robert N M Watson



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060302163633.H77029>