[webkit-dev] More C++11 in WebKit2!

Maciej Stachowiak mjs at apple.com
Mon Apr 29 15:17:49 PDT 2013


On Apr 29, 2013, at 10:33 AM, Anders Carlsson <andersca at apple.com> wrote:

> 
> On Apr 28, 2013, at 1:00 PM, Geoffrey Garen <ggaren at apple.com> wrote:
> 
>> Hi Mikhail.
>> 
>>> In continuation of the topic I'd like also to know people's opinion about Pass*Ptr types deprecation:
>> 
>> I don't think this is appropriate until the compilers on all our major target platforms support C++11. I believe Windows is currently the primary barrier.
>> 
>> Once we have C++11 on all our major target platforms, I think it would great to adopt C++11 idioms throughout the project. 
>> 
>> I believe that part of our reasoning for deploying C++11 idioms in WebKit2 is that it meets this criterion.
> 
> I agree.
> 
> In WebKit2 we have much more freedom to do C++11 experimentation, both due to not having to think about Windows but also due to the fact that WebKit2 is about one fifth the size of WebCore when it comes to number of lines of code.
> 
> When we come up with successful C++11 design patterns and idioms in WebKit2, we can apply them to WebCore when the time is ready. (One thing I’m playing with in WebKit2 is to stop using PassOwnPtr and just using std::move instead).

I feel like consumeValue(std::move(localTemporary)) is less understandable than consumeValue(localTemporary.release()). But I guess that's just surface syntax. Here's a few things I am interested in about the effects effect of this.

I think a lot of the helpfulness of the Pass* types is in the following scenarios:

== Scenario A ==

PassOwnPtr<T> valueProducer() { ... }
void valueConsumer(const PassOwnPtr<T>&) { ... }

void someOtherFunc()
{
    valueConsumer(valueProducer());
}

-- Is this still doable with std::move / rvalues? If so what does it look like?
-- Will it be possible to have typechecking fail if you try to give valueConsumer a regular smart pointer instead of a "movable" one?


== Scenario B ==

PassOwnPtr<T> valueProducer() { ... }
void valueConsumer(const PassOwnPtr<T>&) { ... }

void someOtherFunc()
{
    OwnPtr<T> temporaryLocal = valueProducer();
    temporaryLocal->someSideEffect();
    valueConsumer(temporaryLocal.release());
}

-- Is this still doable with std::move / rvalues? If so what does it look like?
-- Will it be possible to have typechecking fail if you try to give valueConsumer a regular smart pointer instead of a "movable" one, i.e. you forget the release/move?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20130429/70d97155/attachment.html>


More information about the webkit-dev mailing list