<div dir="ltr">Do things get any better if we combine the proposed changes and remove the bare case? Begin function reference with some symbol (# here but it doesn&#39;t matter), only use back tics to disambiguate keywords (which lines up with their current use) and remove the unadorned case to avoid ambiguity.<div><br></div><div><div>```swift </div><div>class Foo {</div><div><span class="" style="white-space:pre">        </span>func doSomething() { }</div><div><span class="" style="white-space:pre">        </span>func doSomething(value: Int) { }</div><div><span class="" style="white-space:pre">        </span>func sub</div><div>}</div><div><br></div><div>let fn = Foo#doSomething // no longer allowed</div><div>let fn = Foo#doSomething() // okay</div><div>let fn2 = Foo#doSomething(_:) // okay</div><div><br></div><div>// and</div><div><br></div><div>let getRow = someMatrix#`subscript`(row:).get</div><div><br></div><div>```</div></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Dec 27, 2015 at 10:40 PM, Douglas Gregor via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><blockquote type="cite"><div>On Dec 27, 2015, at 12:27 AM, Frederick Kellison-Linn via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span></span></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><span></span></div><div><div><span></span></div><div><div>Given that<span> </span><font face="Menlo" style="font-size:11px">someView.insertSubview(_:at:)</font><span> </span>can be correctly parsed, I would strongly lean towards the no-backtick alternative mentioned at the end. I feel as though the backticks end up looking very cluttered (particularly when you get into the double-nested backticks), and it seems cleaner to be able to reference a method as it was declared rather than having to add extra syntax.</div><div><br></div><div>In reference to the issues noted with this approach:</div><div><br></div><div>IMO, there is already enough syntactic difference between getters/setters and normal methods to justify requiring a different syntax to reference them. For instance, the<span> </span><font face="Menlo">#</font> syntax could be used so that,<span> </span><font face="Menlo" style="font-size:11px">button.currentTitle.get</font><span> </span>would reference<span> </span><font face="Menlo" style="font-size:11px">Optional&lt;String&gt;.get</font>, and<span> </span><font face="Menlo" style="font-size:11px">button.currentTitle#get</font> would reference the getter. Or, <span style="font-family:Menlo;font-size:11px">button.`currentTitle.get`</span> could reference the getter (i.e. backticks are only required in cases that are ambiguous).</div><div><br></div><div>I also think it is reasonable to require that in the case of a method with no arguments such as <font face="Menlo" style="font-size:11px">set.removeAllElements</font><font>, the programmer be expected to know the difference between the expression with and without the trailing parenthesis. After all, that distinction already exists in the language, and would not disappear with this proposed addition. If a parallel syntax for referencing methods with no arguments is strongly desired, perhaps something such as </font><span style="font-family:Menlo;font-size:11px">set.removeAllElements(:)</span>, <span style="font-family:Menlo;font-size:11px">set#removeAllElements()</span>, or similar could be used, though I think that the present system for referencing these methods is sufficient.</div><div><font><br></font></div><div>Are there other obvious reasons why this alternative wouldn’t work? I think it is the cleanest of the alternatives and avoids littering the code with backticks.</div></div></div></div></div></blockquote><div><br></div></span><div>Not having the back-ticks means that you will need to use contextual type information to disambiguate the zero-parameter case from other cases. For example:</div><div><br></div><div><span style="white-space:pre-wrap">        </span>class Foo {</div><div><span style="white-space:pre-wrap">                </span>func doSomething() { }</div><div><span style="white-space:pre-wrap">                </span>func doSomething(value: Int) { }</div><div><span style="white-space:pre-wrap">        </span>}</div><div><br></div><div><span style="white-space:pre-wrap">        </span>let fn = Foo.doSomething // ambiguous</div><div><span style="white-space:pre-wrap">        </span>let fn2 = Foo.doSomething(_:) // okay</div><div><span style="white-space:pre-wrap">        </span>let fn3: (Foo) -&gt; () -&gt; Void = Foo.doSomething // okay</div><div><span style="white-space:pre-wrap">        </span>let fn3: (Foo) -&gt; (Int) -&gt; Void = Foo.doSomething // okay</div><div><br></div><div>My general complaint with the “drop the backticks” approach is that it doesn’t solve the whole problem. Sure, it solves 95% of the problem with a little less syntax, but now you need to invent yet another mechanism to handle the other cases (#set, contextual type disambiguation, etc)… which seems inconsistent to me.</div><div><br></div><div><span style="white-space:pre-wrap">        </span>- Doug</div><div><br></div><br><blockquote type="cite"><div><div><div class="h5"><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div><div><div>On Dec 26, 2015, at 11:22 PM, Douglas Gregor via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div>Hi all,<div><br></div><div>Here’s a proposal draft to allow one to name any function in Swift. In effect, it’s continuing the discussion of retrieving getters and setters as functions started by Michael Henson here:</div><div><br></div><div><span style="white-space:pre-wrap">        </span><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/002168.html" target="_blank">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/002168.html</a></div><div><br></div><div>the proposal follows, and is available here as well:</div><div><br></div><div><span style="white-space:pre-wrap">        </span><a href="https://github.com/DougGregor/swift-evolution/blob/generalized-naming/proposals/0000-generalized-naming.md" target="_blank">https://github.com/DougGregor/swift-evolution/blob/generalized-naming/proposals/0000-generalized-naming.md</a></div><div><br></div><div>Comments appreciated!</div><div><br></div><div><h1 style="font-size:2.25em;margin-right:0px;margin-bottom:16px;margin-left:0px;line-height:1.2;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255);margin-top:0px!important">Generalized Naming for Any Function</h1><ul style="padding:0px 0px 0px 2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><li>Proposal: <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0000-generalized-naming.md" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">SE-NNNN</a></li><li>Author(s): <a href="https://github.com/DougGregor" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">Doug Gregor</a></li><li>Status: <strong>Awaiting Review</strong></li><li>Review manager: TBD</li></ul><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://github.com/DougGregor/swift-evolution/blob/generalized-naming/proposals/0000-generalized-naming.md#introduction" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><span style="font-weight:normal;font-size:16px;line-height:1;font-family:octicons;display:inline-block;vertical-align:middle"></span></a>Introduction</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">Swift includes support for first-class functions, such that any function (or method) can be placed into a value of function type. However, it is not possible to specifically name every function that is part of a Swift program---one cannot provide the argument labels when naming a function, nor are property and subscript getters and setters referenceable. This proposal introduces a general syntax that allows one to name anything that is a function within Swift in an extensible manner.</p><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">Swift-evolution thread: Michael Henson started a thread about the getter/setter issue <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/002168.html" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">here</a>, continued <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/002203.html" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">here</a>. See the <a href="https://github.com/DougGregor/swift-evolution/blob/generalized-naming/proposals/0000-generalized-naming.md#alternatives-considered" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">Alternatives considered</a> section for commentary on that discussion.</p><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://github.com/DougGregor/swift-evolution/blob/generalized-naming/proposals/0000-generalized-naming.md#motivation" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><span style="font-weight:normal;font-size:16px;line-height:1;font-family:octicons;display:inline-block;vertical-align:middle"></span></a>Motivation</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">It&#39;s fairly common in Swift for multiple functions or methods to have the same &quot;base name&quot;, but be distinguished by parameter labels. For example, <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">UIView</code> has three methods with the same base name <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">insertSubview</code>:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal"><span style="color:rgb(167,29,93)">extension</span> UIView {
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">insertSubview</span>(view: UIView, at <span>index</span>: <span style="color:rgb(0,134,179)">Int</span>)
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">insertSubview</span>(view: UIView, aboveSubview <span>siblingSubview</span>: UIView)
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">insertSubview</span>(view: UIView, belowSubview <span>siblingSubview</span>: UIView)
}</pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">When calling these methods, the argument labels distinguish the different methods, e.g.,</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal">someView<span style="color:rgb(167,29,93)">.</span>insertSubview(view, at: <span style="color:rgb(0,134,179)">3</span>)
someView<span style="color:rgb(167,29,93)">.</span>insertSubview(view, aboveSubview: otherView)
someView<span style="color:rgb(167,29,93)">.</span>insertSubview(view, belowSubview: otherView)</pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">However, when referencing the function to create a function value, one cannot provide the labels:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal"><span style="color:rgb(167,29,93)">let</span> fn <span style="color:rgb(167,29,93)">=</span> someView<span style="color:rgb(167,29,93)">.</span>insertSubview <span style="color:rgb(150,152,150)">// ambiguous: could be any of the three methods</span></pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">In some cases, it is possible to use type annotations to disambiguate:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal"><span style="color:rgb(167,29,93)">let</span> fn: (UIView, <span style="color:rgb(0,134,179)">Int</span>) <span style="color:rgb(167,29,93)">=</span> someView<span style="color:rgb(167,29,93)">.</span>insertSubview    <span style="color:rgb(150,152,150)">// ok: uses insertSubview(_:at:)</span>
<span style="color:rgb(167,29,93)">let</span> fn: (UIView, UIView) <span style="color:rgb(167,29,93)">=</span> someView<span style="color:rgb(167,29,93)">.</span>insertSubview <span style="color:rgb(150,152,150)">// error: still ambiguous!</span></pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">To resolve the latter case, one must fall back to creating a closure:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal"><span style="color:rgb(167,29,93)">let</span> fn: (UIView, UIView) <span style="color:rgb(167,29,93)">=</span> { view, otherView <span style="color:rgb(167,29,93)">in</span>
  button<span style="color:rgb(167,29,93)">.</span>insertSubview(view, otherView)
}</pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">which is painfully tedious. A similar workaround is required to produce a function value for a getter of a property, e.g.,</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal"><span style="color:rgb(167,29,93)">extension</span> UIButton {
  <span style="color:rgb(167,29,93)">var</span> currentTitle: <span style="color:rgb(0,134,179)">String</span>? { <span style="color:rgb(167,29,93)">...</span> }
}

<span style="color:rgb(167,29,93)">var</span> fn: () <span style="color:rgb(167,29,93)">-&gt;</span> <span style="color:rgb(0,134,179)">String</span>? <span style="color:rgb(167,29,93)">=</span> { () <span style="color:rgb(167,29,93)">in</span>
  <span style="color:rgb(167,29,93)">return</span> button<span style="color:rgb(167,29,93)">.</span>currentTitle
}</pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">One additional bit of motivation: Swift should probably get some way to ask for the Objective-C selector for a given method (rather than writing a string literal). The argument to such an operation would likely be a reference to a method, which would benefit from being able to name any method, including getters and setters.</p><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://github.com/DougGregor/swift-evolution/blob/generalized-naming/proposals/0000-generalized-naming.md#proposed-solution" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><span style="font-weight:normal;font-size:16px;line-height:1;font-family:octicons;display:inline-block;vertical-align:middle"></span></a>Proposed solution</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">Swift currently has a back-tick escaping syntax that lets one use keywords for names, which would otherwise fail to parse. For example,</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal"><span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">`try`</span>() <span style="color:rgb(167,29,93)">-&gt;</span> <span style="color:rgb(0,134,179)">Bool</span> { <span style="color:rgb(167,29,93)">...</span> }</pre></div><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">declares a function named <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">try</code>, even though <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">try</code> is a keyword. I propose to extend the back-tick syntax to allow compound Swift names (e.g., <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">insertSubview(_:aboveSubview:)</code>) and references to the accessors of properties (e.g., the getter for <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">currentTitle</code>). Specifically,</p><ul style="padding:0px 0px 0px 2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><li><p style="margin-top:16px;margin-bottom:16px">Compound names can be written entirely within the back-ticks, e.g.,</p><div style="margin-bottom:16px"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal"><span style="color:rgb(167,29,93)">let</span> fn <span style="color:rgb(167,29,93)">=</span> someView<span style="color:rgb(167,29,93)">.</span>`insertSubview(_:at:)`
<span style="color:rgb(167,29,93)">let</span> fn1 <span style="color:rgb(167,29,93)">=</span> someView<span style="color:rgb(167,29,93)">.</span>`insertSubview(_:aboveSubview:)`</pre></div><p style="margin-top:16px;margin-bottom:16px">The same syntax can also refer to initializers, e.g.,</p><div style="margin-bottom:16px"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal"><span style="color:rgb(167,29,93)">let</span> buttonFactory <span style="color:rgb(167,29,93)">=</span> UIButton<span style="color:rgb(167,29,93)">.</span>`<span style="color:rgb(167,29,93)">init</span>(type:)`</pre></div></li><li><p style="margin-top:16px;margin-bottom:16px">Getters and setters can be written using dotted syntax within the back-ticks:</p><div style="margin-bottom:16px"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal"><span style="color:rgb(167,29,93)">let</span> specificTitle <span style="color:rgb(167,29,93)">=</span> button<span style="color:rgb(167,29,93)">.</span>`currentTitle<span style="color:rgb(167,29,93)">.</span><span style="color:rgb(167,29,93)">get</span>` <span style="color:rgb(150,152,150)">// has type () -&gt; String?</span>
<span style="color:rgb(167,29,93)">let</span> otherTitle <span style="color:rgb(167,29,93)">=</span> UIButton<span style="color:rgb(167,29,93)">.</span>`currentTitle<span style="color:rgb(167,29,93)">.</span><span style="color:rgb(167,29,93)">get</span>`  <span style="color:rgb(150,152,150)">// has type (UIButton) -&gt; () -&gt; String?</span>
<span style="color:rgb(167,29,93)">let</span> setTintColor <span style="color:rgb(167,29,93)">=</span> button<span style="color:rgb(167,29,93)">.</span>`tintColor<span style="color:rgb(167,29,93)">.</span><span style="color:rgb(167,29,93)">set</span>`     <span style="color:rgb(150,152,150)">// has type (UIColor!) -&gt; ()</span></pre></div><p style="margin-top:16px;margin-bottom:16px">The same syntax works with subscript getters and setters as well, using the full name of the subscript:</p><div style="margin-bottom:16px"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal"><span style="color:rgb(167,29,93)">extension</span> Matrix {
  <span style="color:rgb(167,29,93)">subscript</span> (row row: <span style="color:rgb(0,134,179)">Int</span>) <span style="color:rgb(167,29,93)">-&gt;</span> [<span style="color:rgb(0,134,179)">Double</span>] {
    <span style="color:rgb(167,29,93)">get</span> { <span style="color:rgb(167,29,93)">...</span> }
    <span style="color:rgb(167,29,93)">set</span> { <span style="color:rgb(167,29,93)">...</span> }
  }
}

<span style="color:rgb(167,29,93)">let</span> getRow <span style="color:rgb(167,29,93)">=</span> someMatrix<span style="color:rgb(167,29,93)">.</span>`<span style="color:rgb(167,29,93)">subscript</span>(row:)<span style="color:rgb(167,29,93)">.</span><span style="color:rgb(167,29,93)">get</span>` <span style="color:rgb(150,152,150)">// has type (Int) -&gt; () -&gt; [Double]</span>
<span style="color:rgb(167,29,93)">let</span> setRow <span style="color:rgb(167,29,93)">=</span> someMatrix<span style="color:rgb(167,29,93)">.</span>`<span style="color:rgb(167,29,93)">subscript</span>(row:)<span style="color:rgb(167,29,93)">.</span><span style="color:rgb(167,29,93)">set</span>` <span style="color:rgb(150,152,150)">// has type (Int) -&gt; ([Double]) -&gt; ()</span></pre></div><p style="margin-top:16px;margin-bottom:16px">If we introduce property behaviors into Swift, the back-tick syntax could also be used to refer to behaviors, e.g., accessing the <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">lazy</code> behavior of a property:</p><div style="margin-bottom:16px"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal"><span style="color:rgb(167,29,93)">self</span><span style="color:rgb(167,29,93)">.</span>`myProperty<span style="color:rgb(167,29,93)">.</span><span style="color:rgb(167,29,93)">lazy</span>`<span style="color:rgb(167,29,93)">.</span>clear()</pre></div></li><li><p style="margin-top:16px;margin-bottom:16px">Base names that are meaningful keywords (<code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">init</code> and <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">subscript</code>) can be escaped with a nested pair of back-ticks:</p><div style="margin-bottom:16px"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal"><span style="color:rgb(167,29,93)">extension</span> Font {
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">`subscript`</span>() <span style="color:rgb(167,29,93)">-&gt;</span> Font {
    <span style="color:rgb(150,152,150)">// return the subscript version of the given font</span>
  }
}

<span style="color:rgb(167,29,93)">let</span> getSubscript <span style="color:rgb(167,29,93)">=</span> font<span style="color:rgb(167,29,93)">.</span>``<span style="color:rgb(167,29,93)">subscript</span>`()` <span style="color:rgb(150,152,150)">// has type () -&gt; Font</span></pre></div></li></ul><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">The &quot;produce the Objective-C selector for the given method&quot; operation will be the subject of a separate proposal. However, here is one possibility that illustrations how it uses the proposed syntax here:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal"><span style="color:rgb(167,29,93)">let</span> getter: Selector <span style="color:rgb(167,29,93)">=</span> objc_selector(NSDictionary<span style="color:rgb(167,29,93)">.</span>`<span style="color:rgb(167,29,93)">subscript</span>(_:)<span style="color:rgb(167,29,93)">.</span><span style="color:rgb(167,29,93)">get</span>`) <span style="color:rgb(150,152,150)">// produces objectForKeyedSubscript:</span>
<span style="color:rgb(167,29,93)">let</span> setter: Selector <span style="color:rgb(167,29,93)">=</span> objc_selector(NSDictionary<span style="color:rgb(167,29,93)">.</span>`<span style="color:rgb(167,29,93)">subscript</span>(_:)<span style="color:rgb(167,29,93)">.</span><span style="color:rgb(167,29,93)">set</span>`) <span style="color:rgb(150,152,150)">// produces setObject:forKeyedSubscript:</span></pre></div><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://github.com/DougGregor/swift-evolution/blob/generalized-naming/proposals/0000-generalized-naming.md#impact-on-existing-code" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><span style="font-weight:normal;font-size:16px;line-height:1;font-family:octicons;display:inline-block;vertical-align:middle"></span></a>Impact on existing code</h2><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255)">This is a purely additive feature that has no impact on existing code. The syntactic space it uses is already present, and it merely extends the use of back-ticks from storing a single identifier to more complex names.</p><h2 style="margin-top:1em;margin-bottom:16px;line-height:1.225;font-size:1.75em;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;background-color:rgb(255,255,255)"><a href="https://github.com/DougGregor/swift-evolution/blob/generalized-naming/proposals/0000-generalized-naming.md#alternatives-considered" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none;display:inline-block;padding-right:2px;line-height:1" target="_blank"><span style="font-weight:normal;font-size:16px;line-height:1;font-family:octicons;display:inline-block;vertical-align:middle"></span></a>Alternatives considered</h2><ul style="padding:0px 0px 0px 2em;margin-top:0px;color:rgb(51,51,51);font-family:&#39;Helvetica Neue&#39;,Helvetica,&#39;Segoe UI&#39;,Arial,freesans,sans-serif,&#39;Apple Color Emoji&#39;,&#39;Segoe UI Emoji&#39;,&#39;Segoe UI Symbol&#39;;font-size:16px;background-color:rgb(255,255,255);margin-bottom:0px!important"><li><p style="margin-top:16px;margin-bottom:16px">Michael Henson <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/002168.html" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">proposed</a> naming getters and setters using <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">#</code> syntax followed by <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">get</code> or <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">set</code>, e.g.,</p><div style="margin-bottom:16px"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal"><span style="color:rgb(167,29,93)">let</span> specificTitle <span style="color:rgb(167,29,93)">=</span> button<span style="color:rgb(167,29,93)">.</span>currentTitle#<span style="color:rgb(167,29,93)">get</span></pre></div><p style="margin-top:16px;margin-bottom:16px">The use of postfix <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">#</code> is a reasonable alternative here, and more lightweight than two back-ticks for the simple getter/setter case. The notion could be extended to allow argument labels for functions, discussed <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/002210.html" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">here</a>. The proposals in that discussion actually included type annotations as well, but the syntax seems cleaner---and more directly focused on <em>names</em>---without them, e.g.,:</p><div style="margin-bottom:16px"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal"><span style="color:rgb(167,29,93)">let</span> fn <span style="color:rgb(167,29,93)">=</span> someView<span style="color:rgb(167,29,93)">.</span>insertSubview#(_:at:)</pre></div><p style="margin-top:16px;margin-bottom:16px">which works. I didn&#39;t go with this syntax because (1) it breaks up Swift method names such as <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">insertSubview(_:at:)</code>with an <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">#</code> in the middle, and (2) while useful, this feature doesn&#39;t seem important enough to justify overloading <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">#</code>further.</p></li><li><p style="margin-top:16px;margin-bottom:16px">Joe Groff <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/003008.html" style="background-color:transparent;color:rgb(64,120,192);text-decoration:none" target="_blank">notes</a> that <em>lenses</em> are a better solution than manually retrieving getter/setter functions when the intent is to actually operate on the properties. That weakens the case this proposal makes for making getters/setters available as functions. However, it doesn&#39;t address the general naming issue or the desire to retrieve the Objective-C selector for a getter/setter.</p></li><li><p style="margin-top:16px;margin-bottom:16px">Can we drop the back-ticks? It&#39;s very tempting to want to drop the back-ticks entirely, because something like</p><div style="margin-bottom:16px"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal"><span style="color:rgb(167,29,93)">let</span> fn <span style="color:rgb(167,29,93)">=</span> someView<span style="color:rgb(167,29,93)">.</span>insertSubview(_:at:)</pre></div><p style="margin-top:16px;margin-bottom:16px">can be correctly parsed as a reference to <code style="font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">insertSubview(_:at:)</code>. However, it breaks down at the margins, e.g., with getter/setter references or no-argument functions:</p><div style="margin-bottom:16px"><pre style="overflow:auto;font-family:Consolas,&#39;Liberation Mono&#39;,Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-wrap:normal;word-break:normal"><span style="color:rgb(167,29,93)">extension</span> <span style="color:rgb(0,134,179)">Optional</span> {
  <span style="color:rgb(167,29,93)">func</span> <span style="color:rgb(121,93,163)">get</span>() <span style="color:rgb(167,29,93)">-&gt;</span> T { <span style="color:rgb(167,29,93)">return</span> <span style="color:rgb(167,29,93)">self</span><span style="color:rgb(167,29,93)">!</span> }
}

<span style="color:rgb(167,29,93)">let</span> fn1 <span style="color:rgb(167,29,93)">=</span> button<span style="color:rgb(167,29,93)">.</span>currentTitle<span style="color:rgb(167,29,93)">.</span><span style="color:rgb(167,29,93)">get</span>   <span style="color:rgb(150,152,150)">// getter or Optional&lt;String&gt;.get?</span>
<span style="color:rgb(167,29,93)">let</span> fn2 <span style="color:rgb(167,29,93)">=</span> <span style="color:rgb(167,29,93)">set</span><span style="color:rgb(167,29,93)">.</span>removeAllElements()   <span style="color:rgb(150,152,150)">// call or reference?</span></pre></div></li></ul><div><br></div></div><div><br></div><div><span style="white-space:pre-wrap">        </span>- Doug</div><div><br></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=xuNk3-2BDhTcLCDO7Sfs7vOE8RaV6tazapi-2F-2FC6t9siri7wqPwj3GTvcsesCn0HCG6qbJOesGeRvdcCHYn8YNs-2B33qAo05m-2FcE15wjx0YFhkMSPKBonVF9XH7KjNWaWg5rjebvzIvHBYbEiZFWK4YgJwDdCAOM16M9EyTB7HFifNwMcCf7jx7srduho1hnunFaproD8Tw9yUpavWrFiHWRug-3D-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0px!important;margin:0px!important;padding:0px!important"></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></div></div></div></div></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=XbU4wxnU83GyR7TGhOdBtBOchMF7PYvaYPXWDKda2ffTOeR-2BLrUS2cXpCI5wePnWtguWA-2FpwD34TY4-2B37fOYqRlvRBIPqv9pfe-2FPUhuCCJFq3L6XVoD-2FonkVTKBGplgr0eQNgGCilX-2FQfb1oUXhCt0mj4NNuIVFxi2RQbodo9-2FAXoR-2BpM4e9QcQ-2BRa5jvpehMdC0XDpmiw1yLqe6TjwwkXrJm1Y5lsP6XfSrLT7N3Ic-3D" alt="" width="1" height="1" border="0" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;min-height:1px!important;width:1px!important;border-width:0px!important;margin:0px!important;padding:0px!important"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important"><span> </span>_______________________________________________</span><span class=""><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">swift-evolution mailing list</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="mailto:swift-evolution@swift.org" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">swift-evolution@swift.org</a><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span></div></blockquote></div><br>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=3FGfocPbgxkNkmje7djckg9Iw-2BGYY3X6RxJ1tkUXKCoYDOSKYhI4LWPG4aSBKAdirCOIghgFQiIL2oHKWBSOi4d-2FYhpIFZWhMCkBJWp-2FUrEq5OlgFkrQU1zPSN8nLm5nYq2rdp4dgjEy7HsA1iRvkE6j-2BbGlbJTALMYANhqsa6eccwD-2F8pdEQDHz3nWxHj3SUvGfTd-2FCbfrZ510dt3zjtZYUomS0a9j94WWcUVjkEa0-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
</div>
<br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>