[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Java
> And C++ has unwind-protect!:
>
> I always hated that you had to make these little phony classes every
> time you wanted an unwind-protect. The scope of the unwind-protect
> was effectively denoted by the curly-braces that enclosed the instance
> of the little class, but it was not prima facie obvious that those
> curlies were unwind-protect boundaries.
I actually think this is one of C++'s nicer idioms. It can be annoying
having to create the cleanup class, but it turns out there are a small
number of common reusable cases (.e.g, unlocking mutexes, closing files,
freeing pointers). It is also nice that you do not have to create a new
scope in order to define additional cleanup objects, which would otherwise
make your code harder to read.
- Christopher
- References:
- Re: Java
- From: Dan Weinreb <dlw@exceloncorp.com>