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

Maciej Stachowiak mjs at apple.com
Tue Dec 27 00:30:47 PST 2016


> On Dec 26, 2016, at 9:04 AM, Saam Barati <sbarati at apple.com> wrote:
> 
> Right. I see what you're saying. The name doesn't confuse me with respect to these semantics but I see that's it's subtly wrong.
> 
> The use case I was thinking of is this:
> `
> class Foo {
>    Foo() : m_change(someIntVariable, 20) { }
>    ...
>    ...
>    ScopedChange<int> m_change;
> };
> `
> 
> Which is admittedly an odd use case that probably doesn't exist in WebKit. However, if this use case were common, the name ScopedChange feels wrong for it. 

When you have a class intended for RAII-like use, making it also work as a data member or a heap object is a bit of a fool's errand. So I think it's ok to not account for this. If there was a sensible way to make a class only usable as local variable stack objects then this would be a great place to do it, though I don't think C++ has a good way to do that.

Regards,
Maciej



More information about the webkit-dev mailing list