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

Tom Hawtin Thomas.Hawtin at Sun.COM
Mon Mar 30 04:15:00 PDT 2009


Neal Gafter wrote:
> The proposed syntax is ambiguous.  If one writes
> 
> try
> try stmt;
> catch(...) stmt;
> catch(...) stmt;
> finally stmt;
> 
> To which try statement is the second catch block attached?  Please provide an unambiguous syntactic grammar if you still would like your proposal evaluated.

There is obvious precedent in the infamous dangling-else ambiguity - 
catch/finally go with the innermost appropriate try.

(FWIW, IMO there should be a lint warning for any "missing braces" 
(non-block statement) on a if/else/while/do/for.)

Tom Hawtin



More information about the coin-dev mailing list