<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>194930</bug_id>
          
          <creation_ts>2019-02-21 19:51:36 -0800</creation_ts>
          <short_desc>Codify the naming convention for fooIfExists</short_desc>
          <delta_ts>2019-03-01 11:22:33 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKit Website</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ryosuke Niwa">rniwa</reporter>
          <assigned_to name="Ryosuke Niwa">rniwa</assigned_to>
          <cc>darin</cc>
    
    <cc>dbates</cc>
    
    <cc>fujii</cc>
    
    <cc>ggaren</cc>
    
    <cc>jond</cc>
    
    <cc>mjs</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1508845</commentid>
    <comment_count>0</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-02-21 19:51:36 -0800</bug_when>
    <thetext>See https://lists.webkit.org/pipermail/webkit-dev/2013-June/025056.html

Better late than never.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1508846</commentid>
    <comment_count>1</comment_count>
      <attachid>362688</attachid>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-02-21 19:53:35 -0800</bug_when>
    <thetext>Created attachment 362688
Updates the style guideline</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1508852</commentid>
    <comment_count>2</comment_count>
      <attachid>362688</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2019-02-21 20:03:07 -0800</bug_when>
    <thetext>Comment on attachment 362688
Updates the style guideline

Looks fine</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1508853</commentid>
    <comment_count>3</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-02-21 20:04:28 -0800</bug_when>
    <thetext>I&apos;d wait a day or two to give a chance for people to respond on webkit-dev in the case they don&apos;t like this convention since the discussion happened 5 years ago.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1508855</commentid>
    <comment_count>4</comment_count>
      <attachid>362688</attachid>
    <who name="alan">zalan</who>
    <bug_when>2019-02-21 20:14:50 -0800</bug_when>
    <thetext>Comment on attachment 362688
Updates the style guideline

View in context: https://bugs.webkit.org/attachment.cgi?id=362688&amp;action=review

&gt; Websites/webkit.org/ChangeLog:8
&gt; +        Updating the coding style guidleline after the discussion following

guideline</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1508885</commentid>
    <comment_count>5</comment_count>
      <attachid>362688</attachid>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2019-02-21 21:29:59 -0800</bug_when>
    <thetext>Comment on attachment 362688
Updates the style guideline

View in context: https://bugs.webkit.org/attachment.cgi?id=362688&amp;action=review

&gt; Websites/webkit.org/code-style.md:686
&gt; +```cpp
&gt; +StyleResolver* styleResolverIfExists();
&gt; +StyleResolver&amp; styleResolver();
&gt; +```

First, if I were to vote today (02/21/2019), I would vote for StyleResolver&amp; styleResolver() and StyleResolver* existingStyleResolver(), which was what Darin suggested when he wrote &quot;I can’t remember what we decided on for our convention. I personally prefix the thing()/existingThing() pairing, but maybe I was outvoted?&quot; in bug #194764, comment 18. Since Darin r+&apos;ed this patch I guess he changed his mind. Funny thing though, if he didn&apos;t change his mind then his vote and mine would tip the scale towards:

StyleResolver&amp; styleResolver() and StyleResolver* existingStyleResolver()

Funny, huh?

I don&apos;t know how you came to think StyleResolver* styleResolverIfExists() and StyleResolver&amp; styleResolver() are the &quot;right&quot; choice, but Darin r+&apos;ed it. So, I guess he warmed up to styleResolverIfExists() even though he started that webkit-dev thread you mentioned with &quot;Lets bike shed! For some time, functions with names like **fooIfExists** and ensureFoo have been bothering me.&quot; I went through every single email in that thread (was a different time back made it clear what their position was with a &quot;+1&quot;). Here&apos;s what I found and it disagrees with your choices and I&apos;m only mentioning it for completeness since Darin r+&apos;ed the patch (and again he was the one that was initially unhappy). I did skip a few emails that just gave some other naming suggestions that nobody ever replied to as liking:

Emil A Eklund eae at chromium.org: &lt;https://lists.webkit.org/pipermail/webkit-dev/2013-June/025057.html&gt; (BTW she no longer contributes)
    +1 StyleResolver* optionalStyleResolver() and StyleResolver&amp; requiredStyleResolver()
    But suggested StyleResolver* optionalStyleResolver() and StyleResolver&amp; styleResolver() (So to me this implies these are +1 by her as well)

Geoffrey Garen ggaren at apple.com: &lt;https://lists.webkit.org/pipermail/webkit-dev/2013-June/025076.html&gt;
     &quot;I love this!&quot; to Emil A Eklund&apos;s suggestion of  StyleResolver* optionalStyleResolver() and StyleResolver&amp; styleResolver()

Ryosuke Niwa (You): &lt;https://lists.webkit.org/pipermail/webkit-dev/2013-June/025058.html&gt;
    Suggest requireStyleResolver()

Darin Adler: &lt;https://lists.webkit.org/pipermail/webkit-dev/2013-June/025060.html&gt;
    &quot;Tentative +1&quot; = 0.5 to Ryosuke&apos;s suggestion of requireStyleResolver(): &quot;I’m warming to this idea. Maybe we can use “require” as a term of art, analogous to the way we use “create”, to mean “create if not already created”&quot;

Simon Fraser: &lt;https://lists.webkit.org/pipermail/webkit-dev/2013-June/025061.html&gt;
    -1 for requireStyleResolver(): &quot;requireStyleResolver() sounds like it would return a bool.&quot;

Maciej Stachowiak: &lt;https://lists.webkit.org/pipermail/webkit-dev/2013-June/025061.html&gt;
    Sounds like not in favor of requireStyleResolver(). Suggests to drop qualifier.

Balazs Kelemen kbalazs at webkit.org: &lt;https://lists.webkit.org/pipermail/webkit-dev/2013-June/025072.html&gt;  (BTW no longer contributes)
    Suggests styleResolverIfExists() and styleResolver()

Timothy Hatcher timothy at apple.com: &lt;https://lists.webkit.org/pipermail/webkit-dev/2013-June/025073.html&gt;:
    Suggests existingStyleResolver() and styleResolver().

Dan Bernstein mitz at apple.com: &lt;https://lists.webkit.org/pipermail/webkit-dev/2013-June/025073.html&gt;
    &quot;I like it.&quot; to Timothy Hatcher&apos;s suggestion.

Filip Pizlo fpizlo at apple.com: &lt;https://lists.webkit.org/pipermail/webkit-dev/2013-June/025119.html&gt;
    Likes styleResolverIfExists(): &quot;That&apos;s why I like &quot;fooIfExists&quot;&quot;

Andreas Kling akling at apple.com: &lt;https://lists.webkit.org/pipermail/webkit-dev/2013-June/025074.html&gt; (BTW no longer contributes)
    &quot;+1 to these two.&quot; to Timothy Hatcher&apos;s suggestion of existingStyleResolver() and styleResolver().

Elliott Sprehn esprehn at chromium.org: &lt;https://lists.webkit.org/pipermail/webkit-dev/2013-June/025080.html&gt; (BTW no longer contributes)
    -1 to existingStyleResolver() and styleResolver(): &quot;This doesn&apos;t make sense since calling styleResolver() again won&apos;t create a new one so it&apos;s also &quot;existing style resolver&quot;.&quot;
    +1 to foo() and ensureFoo()

Maciej Stachowiak mjs at apple.com: &lt;https://lists.webkit.org/pipermail/webkit-dev/2013-June/025083.html&gt;
     Disagrees with Elliott&apos;s suggestion. Suggests &quot;fooIfExists/foo. But I agree with others on the thread that optionalFoo or existingFoo might be better names, particularly given std::optional&quot;

Gavin Barraclough barraclough at apple.com: &lt;https://lists.webkit.org/pipermail/webkit-dev/2013-June/025070.html&gt;
    -1 requireStyleResolver: &quot;I find ‘requireStyleResolver()’ a little confusing.&quot;  Suggests acquireStyleResolver().

My composite breakdown of the responses:

Name for &quot;guaranteed to give you a resolver&quot; function: 

StyleResolver&amp; styleResolver() =&gt; +8 (Emil A Eklund, Geoffrey Garen, Balazs Kelemen, Timothy Hatcher, Dan Bernstein, Andreas Kling, Elliott Sprehn, Maciej Stachowiak)
StyleResolver&amp; requireStyleResolver() =&gt; +1.5 = +1 &quot;Ryosuke Niwa&quot; + 0.5 &quot;Darin Adler&quot;

Name for function that returns, but does not create a resolver:

StyleResolver* styleResolverIfExists() =&gt; +3 (Balazs Kelemen, Filip Pizlo, Maciej Stachowiak)
StyleResolver* existingStyleResolver() =&gt; +3 (Timothy Hatcher, Dan Bernstein, Andreas Kling)
StyleResolver* optionalStyleResolver() =&gt; +2 (Emil A Eklund, Geoffrey Garen)

Adding in my votes and focusing on the winning results:

StyleResolver&amp; styleResolver() =&gt; +9 (Emil A Eklund, Geoffrey Garen, Balazs Kelemen, Timothy Hatcher, Dan Bernstein, Andreas Kling, Elliott Sprehn, Maciej Stachowiak, Daniel Bates)
StyleResolver* existingStyleResolver() =&gt; +4 (Timothy Hatcher, Dan Bernstein, Andreas Kling, Daniel Bates)

Adding in Darin&apos;s votes if he changes his mind back to what he wrote in bug #194764, comment 18, final score is:

StyleResolver&amp; styleResolver() =&gt; +10 (Emil A Eklund, Geoffrey Garen, Balazs Kelemen, Timothy Hatcher, Dan Bernstein, Andreas Kling, Elliott Sprehn, Maciej Stachowiak, Daniel Bates, Darin Adler)
StyleResolver* existingStyleResolver() =&gt; +5 (Timothy Hatcher, Dan Bernstein, Andreas Kling, Daniel Bates, Darin Adler)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1508886</commentid>
    <comment_count>6</comment_count>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2019-02-21 21:35:12 -0800</bug_when>
    <thetext>Darn. I missed some replies that spilled over to July: &lt;https://lists.webkit.org/pipermail/webkit-dev/2013-July/025122.html&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1508889</commentid>
    <comment_count>7</comment_count>
    <who name="Daniel Bates">dbates</who>
    <bug_when>2019-02-21 21:43:56 -0800</bug_when>
    <thetext>Ryosuke Niwa (You): &lt;https://lists.webkit.org/pipermail/webkit-dev/2013-July/025122.html&gt;
   +1 Balazs Kelemen&apos;s StyleResolver* styleResolverIfExists() and StyleResolver&amp; styleResolver(): &quot;Maybe StyleResolver* styleResolverIfExists() StyleResolver&amp; styleResolver()&quot;

Brady Eidson: &lt;https://lists.webkit.org/pipermail/webkit-dev/2013-July/025123.html&gt;
   +1 StyleResolver* styleResolverIfExists() and StyleResolver&amp; styleResolver()

Dan Bernstein mitz at apple.com: &lt;https://lists.webkit.org/pipermail/webkit-dev/2013-July/025124.html&gt;
   +1 StyleResolver* styleResolverIfExists() and StyleResolver&amp; styleResolver()

Maciej Stachowiak mjs at apple.com: &lt;https://lists.webkit.org/pipermail/webkit-dev/2013-July/025130.html&gt;
   +1 StyleResolver* styleResolverIfExists() and StyleResolver&amp; styleResolver()

Bem Jones-Bey bjonesbe at adobe.com: &lt;https://lists.webkit.org/pipermail/webkit-dev/2013-July/025132.html&gt; (BTW no longer contributes)
   +1 StyleResolver* styleResolverIfExists() and StyleResolver&amp; styleResolver()

So, final tally for styleResolver() and styleResolverIfExists(), not including me or Darin:

StyleResolver&amp; styleResolver() =&gt; +10 (Emil A Eklund, Geoffrey Garen, Balazs Kelemen, Timothy Hatcher, Dan Bernstein, Andreas Kling, Elliott Sprehn, Maciej Stachowiak, Brady Eidson, Bem Jones-Bey)

StyleResolver* styleResolverIfExists() =&gt; +7 (Balazs Kelemen, Filip Pizlo, Maciej Stachowiak, Ryosuke Niwa, Dan Bernstein, Brady Eidson, Bem Jones-Bey)

So, even if I voted and Darin changed his mind on styleResolverIfExists(), styleResolverIfExists() would win. Okay. I&apos;m fine with that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1508892</commentid>
    <comment_count>8</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-02-21 22:14:18 -0800</bug_when>
    <thetext>Yeah, it was a pretty lengthy debate and there were many suggestions and up-votes.

It was easier for me to go through because I had an email thread in my email archive. Thanks for summarizing the results though.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1511476</commentid>
    <comment_count>9</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-03-01 11:21:17 -0800</bug_when>
    <thetext>Committed r242273: &lt;https://trac.webkit.org/changeset/242273&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1511478</commentid>
    <comment_count>10</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2019-03-01 11:22:33 -0800</bug_when>
    <thetext>&lt;rdar://problem/48516506&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>362688</attachid>
            <date>2019-02-21 19:53:35 -0800</date>
            <delta_ts>2019-02-21 20:03:07 -0800</delta_ts>
            <desc>Updates the style guideline</desc>
            <filename>bug-194930-20190221195335.patch</filename>
            <type>text/plain</type>
            <size>2020</size>
            <attacher name="Ryosuke Niwa">rniwa</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYnNpdGVzL3dlYmtpdC5vcmcvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFdlYnNp
dGVzL3dlYmtpdC5vcmcvQ2hhbmdlTG9nCShyZXZpc2lvbiAyNDE5MjgpCisrKyBXZWJzaXRlcy93
ZWJraXQub3JnL0NoYW5nZUxvZwkod29ya2luZyBjb3B5KQpAQCAtMSwzICsxLDE1IEBACisyMDE5
LTAyLTIxICBSeW9zdWtlIE5pd2EgIDxybml3YUB3ZWJraXQub3JnPgorCisgICAgICAgIENvZGlm
eSB0aGUgbmFtaW5nIGNvbnZlbnRpb24gZm9yIGZvb0lmRXhpc3RzCisgICAgICAgIGh0dHBzOi8v
YnVncy53ZWJraXQub3JnL3N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UgZm9yIGJvb2xzLCBzdHJpbmdzLCBhbmQgbnVtZXJpY2Fs
IHR5cGVzLgogCiAjIyMjIyMgUmlnaHQ6Cg==
</data>
<flag name="review"
          id="379302"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>