commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory" <>
Subject RE: [lang] return statements [was VOTE 2.1 release]
Date Tue, 12 Apr 2005 16:51:12 GMT
WRT "Better put it in the lang guidelines though."

I do not see any [lang]-specific quidelines, but we have a [commons-*]
guideline page [1] and a Jakarta guideline page [2], both pointing to
Sun's page [3].

On Sun's doc, in the section "7.3 return statements" [4], quote:

A return statement with a value should not use parentheses unless they
make the return value more obvious in some way. Example:


return myDisk.size();

return (size ? size : defaultSize);

End quote.

I suppose what is "obvious" to one just gets in the way for another ;-)
I would prefer less ()'s than more. 

Is it me or does the example above seems like nonsense? Try compiling:

    private int a() {
        return (0 ? 0 : 1);

Unless of course "size" is a boolean... ahem ;-) This is not C...



-----Original Message-----
From: Stephen Colebourne [] 
Sent: Tuesday, April 12, 2005 12:13 AM
To: Jakarta Commons Developers List
Subject: Re: [lang] return statements [was VOTE 2.1 release]

Personally I think its a lot more readable with the brackets (unless its

a simple return). Thus I tend to code as:

return value;
return method();
return (expression);

But if others dislike this, I'll try to remembre not to do it on lang. 
Better put it in the lang guidelines though.


Henri Yandell wrote:
> -1 to return (foo) :)
> You get my vote to commit. I'm pretty sure the general agreement is to
> not have brackets on return statements, but I'm unsure if it's some
> contributors or some committers who like the brackets.
> Hen
> On Apr 11, 2005 6:56 PM, Gary Gregory <>
>>I've committed some small clean ups in the text package which will not
>>be shipped in 2.1.
>>What I found while doing this is a code style inconsistency that I've
>>fixed locally but not committed yet. Since this involves style
>>;-) I did not want to commit without posting here first:
>>Throughout [lang], some return statements are coded as the "standard":
>>        return expression;
>>While others are coded as with extra C-style "(" and ")":
>>        return (expression);
>>I did not find any pattern to either style. I removed extra "(" and
>>in return expressions on my local store.
>>Is this a religious issue for some [lang]'ers out there or should I
>>-----Original Message-----
>>From: Henri Yandell []
>>Sent: Sunday, April 10, 2005 5:54 PM
>>To: Jakarta Commons Developers List
>>Subject: [lang] VOTE 2.1 release
>>Proposing a vote to go ahead and release Commons Lang 2.1.
>>The release will pretty much match the release-candidate that is in:
>>Stephen's recent defaultIfEmpty method will be included in the
>>If the vote is successful, I'll target spending next weekend
>>performing the release (unless anyone wants to volunteer).
>>[ ] +1
>>[ ] -1
>>To unsubscribe, e-mail:
>>For additional commands, e-mail:
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message