commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory" <ggreg...@seagullsoftware.com>
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;

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...

Gary

[1] http://jakarta.apache.org/commons/charter.html
[2] http://jakarta.apache.org/site/library.html
[3] http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html
[4] http://java.sun.com/docs/codeconv/html/CodeConventions.doc6.html#438

-----Original Message-----
From: Stephen Colebourne [mailto:scolebourne@btopenworld.com] 
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.

Stephe

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 <ggregory@seagullsoftware.com>
wrote:
> 
>>Hello:
>>
>>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
(religion
>>;-) 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
just
>>commit?
>>
>>Thanks,
>>Gary
>>
>>-----Original Message-----
>>From: Henri Yandell [mailto:flamefew@gmail.com]
>>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:
>>http://www.apache.org/~bayard/commons-lang-2.1/
>>
>>Stephen's recent defaultIfEmpty method will be included in the
release.
>>
>>If the vote is successful, I'll target spending next weekend
>>performing the release (unless anyone wants to volunteer).
>>
>>[ ] +1
>>[ ] -1
>>
>>Hen
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message