PROPOSAL: open and close brace optional for single statement try, catch, finally, method declaration

Joseph D. Darcy Joe.Darcy at Sun.COM
Thu May 14 22:41:43 PDT 2009


Catching up on responses...

Glenn A.P. Marshall wrote:
> PROJECT COIN SMALL LANGUAGE CHANGE PROPOSAL FORM v1.0
>
> AUTHOR(S): Glenn Marshall
>
> *OVERVIEW
>
> FEATURE SUMMARY:
>
> Make open and close brace optional for single statement try, catch,  
> finally, method declaration.
>
> (the relatively rarely used single statement static initializer would  
> still require braces under this proposal, due to its relative rarity).
>
> MAJOR ADVANTAGE:
>
> Simple, single statement try blocks, catch blocks, and single  
> statement methods (for example, getter methods) are very common in  
> Java code.  Unlike if, while and do statements, the open and close  
> braces are mandatory even when the target of the keyword is a single  
> statement.  This requirement needlessly clutters the code with  
> unneeded open and close braces, increases code complexity slightly  
> and decreases readability.  Removing this requirement addresses a  
> syntactic inconsistency in Java, whereby braces are required for some  
> single statement keyword targets but not others.
>
> MAJOR BENEFIT:
>
> More readable code, needless syntactic 'noise' removed, consistent  
> treatment of common single statement keyword targets.  Since single  
> statement try, catch, method are very common, these benefits could be  
> applied many times to a typical large Java program.
>   

While there is a little extra clutter in code because of this 
restriction, I don't view that noise as a pressing problem and the lack 
of an unambiguous grammar in the proposal and the absence of a prototype 
do not argue in the proposal's favor.

-Joe



More information about the coin-dev mailing list