
Rob Stewart wrote:
- The naming of arm/disarm methods of scope guard. They are used to change the activity status of the guard. Personally, I feel fine with them but the commonly used name for disabling the guard is "dismiss" and I just can't figure out its suitable counterpart in English. I wonder if anyone have a proposal about this.
"Dismiss" would be the right word in English to tell the guard to go away and do nothing more.
Yes but what about its antipod - a function to enable the guard? Note that the guard may even be initially disabled (that's another reason I didn't like dismiss) and then it may be enabled in some place.
I see. I thought you somehow knew of "dismiss" in another language and didn't know the English word for it.
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();
Well, as for me the "summon" name doesn't look very good. It looks like something should come from the "other side" :). The Brian's proposal ("guard") looks better but intersects with the class name itself. Maybe some other versions?
- The naming of the function make_guarded_call (in previous version it was make_transaction) is what I'm not sure of. This function in addition to a scope_guard creation calls some another functor. The semantic is grouping the "do" and "undo" actions in the user code. Does anyone have a better name?
How about "call_guarded" or "invoke_guarded?"
That might do. But doesn't the common make_ prefix mean that something (a guard in this case) should be created?
I took your question to mean that you were naming a function template that created a guard, called a function (object), and then destroyed the guard. Now it sounds as though you're creating a function object that does that and you want to name the function template that creates the function object. In that case, "make_guarded_caller" sounds about right.
I'm sorry if I made myself not clear enough. The function is supposed to do the following: - Take two function objects - Execute the first one immediately - Create a guard object that will call the second functor on destruction - Return the guard (user may bind it to a reference, which is typedefed to boost::scope_guard) So from the user's point of view the function executes the "do" action and returns a guard to perform "undo" action. This looks like some kind of transaction - the action shall be rolled back unless everything is ok and the result is committed (read: the guard is disarmed). The word "transaction" though is what I'd like to avoid. It is too wide spread an has to do with databases which is not the case.