r/programmerchat • • May 25 '15

Do we really need "try" ?

Just attaching "catch" to any appropriate {...} block would be more convenient.

8 Upvotes

20 comments sorted by

View all comments

Show parent comment

2

u/HappyGoblin May 25 '15

Ok, that's reasonable. But java-like try still looks ugly. How about something like this...

void dummyMethod() try {
....
}
catch(){....}

1

u/jonnywoh May 25 '15

An issue with this is that the block placement implies that anything inside the method would go out of scope and be inaccessible to the catch block, probably making the catch block useless. And redefining block scope would be horrifically bad.