scope guards
Mike Parker via Digitalmars-d
digitalmars-d at puremagic.com
Sun Aug 3 19:04:37 PDT 2014
On 8/4/2014 12:28 AM, Manu via Digitalmars-d wrote:
> I'm trying to make better use of scope guards, but I find myself belting
> out try/catch statements almost everywhere.
> I'm rather disappointed, because scope guards are advertised to offer
> the promise of eliminating try/catch junk throughout your code, and I'm
> just not finding that to be the practical reality.
>
> I think the core of the problem is that scope(failure) is
> indiscriminate, but I want to filter it for particular exceptions. The
> other issue is that you still need a catch() if you don't actually want
> the program to terminate, which implies a try... :/
Scope guards are for when you don't need to handle exceptions. If you
need the exceptions, use try...catch. I don't think it would be a good
idea to have two different means of handling exceptions.
---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com
More information about the Digitalmars-d
mailing list