From: Peter Dimov (pdimov_at_[hidden])
Date: 2005-09-23 15:41:57
Andrey Semashev wrote:
> Peter Dimov wrote:
>> Andrey Semashev wrote:
>>> So, there was a really interesting and hot discussion about namings.
>>> Many opinions were expressed and I'd like to make some roundup.
>> I still think that the question "should X be included at all" is
>> slightly more fundamental than "should X be named rearm, protect, or
>> on". But this may be just me.
> I'm sorry I didn't answer directly to you, but I wrote this in one of
> the descussion threads:
> The more common use case is to create initially disabled guard and
> then, depending on some condition, activate it. I've had the need of
> such functionality several times.
I've tried to construct imaginary use cases that illustrate this, but in my
experience, it is usually not possible to create the guard before acquiring
the resource, because the guard needs to store the acquired resource.
FILE * f = fopen( ... );
if( f == 0 ) throw ...;
scoped_guard file_closer = make_guard( fclose, f );
Even if the fopen is conditional, I can't create the guard and 'arm' it
later, unless 'arm' takes parameters.
Your examples don't carry enough context for me to be able to understand
them. I'm pretty sure I can refactor every 'arm'ing example into one that
doesn't need 'arm', but the interesting question is whether this refactoring
would improve the code. Without some real examples, I can't answer this for
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk