DIP 1002 (TryElseExpression) added to the queue
Idan Arye via Digitalmars-d
digitalmars-d at puremagic.com
Wed Sep 28 15:12:27 PDT 2016
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...
More information about the Digitalmars-d
mailing list