On Wednesday, 28 September 2016 at 21:00:00 UTC, Steven
Schveighoffer wrote:
Declaring variables that you need in the right scopes is pretty
straightforward. Having scopes magically continue around other
separate scopes (catch scopes) doesn't look correct. I get why
it's desired, but it doesn't look clean at all.
-Steve
Consider this:
try {
auto foo = Foo();
} catch (FooCreationException) {
// ...
} else {
foo.doSomethingWithFoo();
}
// foo does not exist here
versus this:
Foo foo;
try {
foo = Foo();
} catch (FooCreationException) {
// ...
} else {
foo.doSomethingWithFoo();
}
// foo exists here - it could be initialized, it could be
not...