On Jun 18, 2013, at 7:03 PM, Emil A Eklund <e...@chromium.org> wrote:

> +1, much clearer and the pointer vs reference makes it even more so.
> Perhaps enough so that the required prefix could be dropped:
> 
> StyleResolver* optionalStyleResolver();
> StyleResolver& styleResolver();

I love this!

On Jun 18, 2013, at 10:16 PM, Ryosuke Niwa <rn...@webkit.org> wrote:

> True. But it's important to differentiate a simple inline accessor and a 
> lazily-create function because it's very easy to write code like:
> 
> if (styleResolver().x())
>     styleResolver().y();

Like Maciej, I disagree on this point.

If we gave special names to every accessor that was not just a load from a 
field, our code would get bloated and not-fun to read:

globalObject->vmWithMaskAndTwoPointerIndirections();
stringImpl->computeAndStoreHashInLinearTime();
etc.

It’s the programmer’s job to understand the efficiency of the primitives he or 
she uses, and to profile hot code to make sure it’s not needlessly inefficient.

On Jun 18, 2013, at 6:38 PM, Darin Adler <da...@apple.com> wrote:

> It seems like the C++ community likes the name optional for this concept; 
> isn’t there some kind of std::optional template?

Yes: 

<http://en.cppreference.com/w/cpp/utility/optional>

The class template std::optional manages an optional contained value. The value 
may be in either initialized or uninitialized state.

Geoff
_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev

Reply via email to