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 23:05:10 GMT
Hello:

WRT "Sorry, see [collections] DEVELOPERS-GUIDE."

Should we create one for [lang]? IMHO, it seems that we can delegate to
the commons code style (Sun + tweaks), unless we think that we should
explicitly guide away from "return (expression);" I would prefer having
a consistent "return expression" in [lang] and not have a dev-guide note
for this.

WRT "The example should probably be a Boolean"

Indeed, this mistake surely comes from the initial Sun "let's make it
easy for C/C++ developers to learn Java" POV.

I'll have to agree to disagree with Stephen on the "return (expression)"
biz. 

Since we've had an informal "-1 to return (foo) :)" from Henri, I'll
commit.

Gary

-----Original Message-----
From: Stephen Colebourne [mailto:scolebourne@btopenworld.com] 
Sent: Tuesday, April 12, 2005 3:36 PM
To: Jakarta Commons Developers List
Subject: Re: [lang] return statements [was VOTE 2.1 release]

Gary Gregory wrote:
> WRT "Better put it in the lang guidelines though."

Sorry, see [collections] DEVELOPERS-GUIDE.

> 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);

The example should probably be a boolean, eg:

  return (isBig() ? size : defaultSize);
  return isBig() ? size : defaultSize;

and, yes, the former is a lot clearer to my eyes (with the brackets).

(For me, the brackets give a mental indication that you must scan the 
whole line to understand it, emphasising that it is a single expression.

Whereas without the brackets, my mind must deduce that it is an 
expression from the return statement, which is more effort)

Stephen

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