On 5 December 2010 13:58, Raphael Langella <raphael.lange...@gmail.com> wrote:
> 2010/12/5 Johanna Ploog <johanna.pl...@googlemail.com>
>>
>> On 5 December 2010 10:07, Jude <bookofj...@gmail.com> wrote:
>> > On Sun, Dec 5, 2010 at 7:01 PM, Raphael Langella
>> > <raphael.lange...@gmail.com> wrote:
>> >> Do not needlessly surround the return expression with parentheses. Only
>> >> do so for long or multi-line expressions.
>> >
>> > I don't like this. Surrounding it with parentheses makes it stand out
>> > better, regardless of whether or not it's short, long, or multi-line.
>>
>> I agree with Jude.
>
> Really? Even for very short expression? Like you prefer
>
> return (true);
>
> over
>
> return true;

Yes. I actually went through the code a couple of times to put
brackets around such statements. :)
As Jude pointed out, it does make it easier to parse the actual return
value at a glance.

return (result);

Granted, for short expressions it doesn't matter too much. At the same
time, I've come to the conclusion that I dislike putting enums into
parentheses, in particular if it happens in a switch-case environment.
Having

case MONS_RAT: return (TILEP_MONS_RAT);
case MONS_GOBLIN: return (TILEP_MONS_GOBLIN);
...

does indeed not improve readability. Or maybe I just dislike capital
letters in brackets; I think I would prefer "return TRUE" over "return
(TRUE)". IMHO, capital letters are attention-raising enough as it is.
Then again, we do have "return (NULL)", but of course this is more
than a simple enum.

For more complex expressions, however, parentheses do actually help.

return (value > foo && value < bar);

However, if the return value already contains parentheses (because
it's a function call, for example) adding more of them can actually
increase confusion potential.

Huh... I wouldn't have thought this to be so complicated.

Johanna

------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly 
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus 
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
Crawl-ref-discuss mailing list
Crawl-ref-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/crawl-ref-discuss

Reply via email to