I sometimes think that it would be very convenient if I can omit brackets('{' , '}') in try/catch for a single statement. (as just same as if/for/while ...)
Not exactly, but try/catch is somewhat similar with 'if' statement in terms about conditional flow change.
I'm tired of typing {} twice whenever I want to handle some exception.
I'm not sure whether allowing that causes any syntactic ambiguity or serious problem, but if it is theoretically possible, then would it be helpful?
Thank you. Stroustrup pointed out the ambiguity. But he said
"There seems to be no reason to allow these ambiguities even if there is a trivial and systematic way for a parser to chose one interpretation over another. ".
Here's my question. What if it is turns out to be really convenient?
if-else has exactly same problem but is allowed by some arbitrary syntactic rule https://en.wikipedia.org/wiki/Dangling_else#C
(Here the rule is just attaching 'else' to the nearest if. )
I don't know the historical background over that issue, but I believe that's because if-else appears too frequently and needs some syntactic help.
Why not for try-catch? It's matter of being actually convenient or not. (I'm not sure about that.)
..I'm tired of typing {} twice whenever I want to handle some exception.
That hints to me that you're may be using exceptions too often for more common error handling instead of exceptional circumstances. If that single statement is a function that does a lot of work, then maybe not, but I don't usually find a great many try/catch clauses.
I write so few try-catch blocks and I prefer to always write the {} even for if statements so it doesn't really affect me, but it is inconsistent, I give you that. Even switch statements allow you to leave out the {} even though it's not very useful.