[webkit-dev] For your consideration: Naming scheme for fooIfExists/ensureFoo

Geoffrey Garen ggaren at apple.com
Wed Jun 19 10:04:28 PDT 2013

On Jun 18, 2013, at 7:03 PM, Emil A Eklund <eae at 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 <rniwa at 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:


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 <darin at 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?



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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20130619/18cebc14/attachment.html>

More information about the webkit-dev mailing list