[webkit-dev] Naming preference: SetForScope vs. TemporaryChange

Maciej Stachowiak mjs at apple.com
Fri Dec 23 06:50:30 PST 2016

A few more coats of paint for the bike shed:

It's a little unusual to have a class name that's a verb phrase instead of a noun phrase. And in this case if you interpret "Set" as a noun you'll get entirely the wrong idea. Some alternatives that avoid this, but has the better clarity of "Scope" instead of "Temporary" would be "ScopedChange or "ScopedAssignment".

One additional thing to think about: the class doesn't just have the effect of limiting the assignment to a scope. It will also undo any further assignments to the reference it holds that happen until it is destroyed. Save-restore semantics like this are common but often the names involved highlight the restore rather than the setting. I can't think of a great name off the top of my head but something like RestoreOnScopeExit seems more technically accurate than SetForScope.

 - Maciej

> On Dec 23, 2016, at 6:32 AM, Michael Catanzaro <mcatanzaro at igalia.com> wrote:
> On Fri, 2016-12-23 at 05:42 +0000, Yusuke SUZUKI wrote:
>> Personally I like the name "SetForScope" since the name "scope"
>> states that this value change is tied to C++ scope.
> Me too. The name is pretty clear. The first time I saw TemporaryChange
> I had to look at the implementation to see what it did.
> Michael
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev

More information about the webkit-dev mailing list