|
Boost : |
From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2005-09-22 10:37:03
"Rob Stewart" <stewart_at_[hidden]> wrote in message
news:200509221407.j8ME7elF003986_at_shannonhoon.balstatdev.susq.com...
> From: Brian Ravnsgaard Riis <brian_at_[hidden]>
>> Andrey Semashev wrote:
>> > Brian Ravnsgaard Riis wrote:
>> >>Rob Stewart wrote:
>> >>
>> >>>I think Markus is right: summon is the opposite of dismiss for a
>> >>>guard. The question is whether it reads well when used:
>> >>>
>> >>> guard g;
>> >>> if (something) g.dismiss();
>> >>> ...
>> >>> if (whatever) g.summon();
>> >>
>> >>"Guard"? Somehow "Summon" doesn't read very well above. I'm sorta
[snip]
> When thinking of someone yelling, "Guard!" this fits pretty well,
> but it can just as easily be thought of as an accessor. Still,
> one has to know what a scope_guard is to understand "dismiss" or
> "guard," so the name is still quite reasonable.
>
> What about "post?" That is, you're "posting a guard." You can
> post a guard after you dismiss him, by implicitly summoning him,
> of course. In this case, the guard never went away, he was just
> told to ignore his charge by dismiss(). Thus, he needn't be
> summoned.
>
> scope_guard g;
> if (a) g.dismiss();
> ...
> if (b) g.post();
>
> Perhaps if the member function were named "guarding" and it took
> a bool, and you provided non-member functions dismiss() and
> post(), this might read better:
>
> scope_guard g;
> if (a) dismiss(g);
> ...
> if (b) post(g);
Carrying the analogy to the extreme:
scope_guard g;
if (a) at_ease(g);
...
if (b) attention(g); // emphasizing the appropriate syllables!
:o)
Jeff
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk