Tell you what, let me wait to commit 'til tomorrow in case more folks
want to weigh in on Stephen's side and we feel this needs more
discussion. This is a minor issue, but what the hay, there no rush ;-)

Gary

-----Original Message-----
From: Gary Gregory [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 12, 2005 4:05 PM
To: Jakarta Commons Developers List
Subject: RE: [lang] return statements [was VOTE 2.1 release]

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:[EMAIL PROTECTED] 
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to