<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><span></span></div><div><div>Commentary inline below.</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">FKL</div><div id="AppleMailSignature"><br></div><div>On Dec 27, 2015, at 8:40 PM, Douglas Gregor &lt;<a href="mailto:dgregor@apple.com">dgregor@apple.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 27, 2015, at 12:27 AM, Frederick Kellison-Linn via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><span class=""></span></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""><span class=""></span></div><div class=""><div class=""><span class=""></span></div><div class=""><div class="">Given that<span class="Apple-converted-space">&nbsp;</span><font face="Menlo" class="" style="font-size: 11px;">someView.insertSubview(_:at:)</font><span class="Apple-converted-space">&nbsp;</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 class=""><br class=""></div><div class="">In reference to the issues noted with this approach:</div><div class=""><br class=""></div><div class="">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 class="Apple-converted-space">&nbsp;</span><font face="Menlo" class="">#</font>&nbsp;syntax could be used so that,<span class="Apple-converted-space">&nbsp;</span><font face="Menlo" class="" style="font-size: 11px;">button.currentTitle.get</font><span class="Apple-converted-space">&nbsp;</span>would reference<span class="Apple-converted-space">&nbsp;</span><font face="Menlo" class="" style="font-size: 11px;">Optional&lt;String&gt;.get</font>, and<span class="Apple-converted-space">&nbsp;</span><font face="Menlo" class="" style="font-size: 11px;">button.currentTitle#get</font>&nbsp;would reference the getter. Or,&nbsp;<span class="" style="font-family: Menlo; font-size: 11px;">button.`currentTitle.get`</span>&nbsp;could reference the getter (i.e. backticks are only required in cases that are ambiguous).</div><div class=""><br class=""></div><div class="">I also think it is reasonable to require that in the case of a method with no arguments such as&nbsp;<font face="Menlo" class="" style="font-size: 11px;">set.removeAllElements</font><font class="">, the programmer be expected to know the difference between the expression with&nbsp;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&nbsp;</font><span class="" style="font-family: Menlo; font-size: 11px;">set.removeAllElements(:)</span>,&nbsp;<span class="" 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 class=""><font class=""><br class=""></font></div><div class="">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 class=""></div><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 class=""></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>class Foo {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>func doSomething() { }</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>func doSomething(value: Int) { }</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>let&nbsp;fn = Foo.doSomething // ambiguous</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>let fn2 = Foo.doSomething(_:) // okay</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>let fn3: (Foo) -&gt; () -&gt; Void = Foo.doSomething // okay</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>let fn3: (Foo) -&gt; (Int) -&gt; Void = Foo.doSomething // okay</div></div></div></blockquote><div><br></div><div><div id="AppleMailSignature"><span style="background-color: rgba(255, 255, 255, 0);">Why does Foo.doSomething have to be ambiguous? I would say that if this system is implemented (especially if without backticks), Foo.doSomething should only be able to refer to the no-argument overload of doSomething (i.e. "let fn3: (Foo) -&gt; (Int) -&gt; Void = Foo.doSomething" would be an error). This would break existing code that relies on the type disambiguation, but we would be able to offer a replacement for it.</span></div></div><br><blockquote type="cite"><div><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></div></blockquote><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">I feel as though backticks are the inconsistent approach in this case, especially because they already have one meaning in Swift that is used in the same context (as Chris notes). The 'natural' solution to me would be to refer to method references by writing them like a call without arguments, just like the name of a selector in Objective C.</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">Backticks also have the unfortunate properties of being relatively unknown characters to those who may not have a lot of programming experience, and at first glance are hard to differentiate from single quotes. In the context of using keywords as identifiers, I don't see those to be as big of issues, because except in very specific cases the easier solution is simply "come up with a different name for your identifier". To have to use backticks whenever a method reference is desired is, IMO, confusing and cluttered syntax.</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">I think that the best solution is to extend the current syntax as naturally as possible, and only introduce the backticks (or other syntax) as needed in cases such as obj.`property.get` (or obj.property#get). Obviously my notion of 'natural' is going to differ from others', but I think that most would agree that being able to write "Foo.doSomething(_:bar:)" is a more intuitive extension of the syntax than "Foo.`doSomething(_:bar:)`.</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><blockquote type="cite"><div><div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>- Doug</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""><div class=""><div class="">On Dec 26, 2015, at 11:22 PM, Douglas Gregor via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class="">Hi all,<div class=""><br class=""></div><div class="">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 class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/002168.html" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/002168.html</a></div><div class=""><br class=""></div><div class="">the proposal follows, and is available here as well:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span><a href="https://github.com/DougGregor/swift-evolution/blob/generalized-naming/proposals/0000-generalized-naming.md" class="">https://github.com/DougGregor/swift-evolution/blob/generalized-naming/proposals/0000-generalized-naming.md</a></div><div class=""><br class=""></div><div class="">Comments appreciated!</div><div class=""><br class=""></div><div class=""><h1 class="" style="box-sizing: border-box; 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: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255); margin-top: 0px !important;">Generalized Naming for Any Function</h1><ul class="" style="box-sizing: border-box; padding: 0px 0px 0px 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><li class="" style="box-sizing: border-box;">Proposal:&nbsp;<a href="https://github.com/apple/swift-evolution/blob/master/proposals/0000-generalized-naming.md" class="" style="box-sizing: border-box; background-color: transparent; color: rgb(64, 120, 192); text-decoration: none;">SE-NNNN</a></li><li class="" style="box-sizing: border-box;">Author(s):&nbsp;<a href="https://github.com/DougGregor" class="" style="box-sizing: border-box; background-color: transparent; color: rgb(64, 120, 192); text-decoration: none;">Doug Gregor</a></li><li class="" style="box-sizing: border-box;">Status:&nbsp;<strong class="" style="box-sizing: border-box;">Awaiting Review</strong></li><li class="" style="box-sizing: border-box;">Review manager: TBD</li></ul><h2 class="" style="box-sizing: border-box; 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: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="user-content-introduction" class="anchor" href="https://github.com/DougGregor/swift-evolution/blob/generalized-naming/proposals/0000-generalized-naming.md#introduction" aria-hidden="true" style="box-sizing: border-box; background-color: transparent; color: rgb(64, 120, 192); text-decoration: none; display: inline-block; padding-right: 2px; margin-left: -18px; line-height: 1;"><span class="octicon octicon-link" style="box-sizing: border-box; font-weight: normal; font-size: 16px; line-height: 1; font-family: octicons; display: inline-block; text-rendering: auto; -webkit-font-smoothing: antialiased; -webkit-user-select: none; vertical-align: middle; visibility: hidden;"></span></a>Introduction</h2><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; 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 class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">Swift-evolution thread: Michael Henson started a thread about the getter/setter issue&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/002168.html" class="" style="box-sizing: border-box; background-color: transparent; color: rgb(64, 120, 192); text-decoration: none;">here</a>, continued&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/002203.html" class="" style="box-sizing: border-box; background-color: transparent; color: rgb(64, 120, 192); text-decoration: none;">here</a>. See the&nbsp;<a href="https://github.com/DougGregor/swift-evolution/blob/generalized-naming/proposals/0000-generalized-naming.md#alternatives-considered" class="" style="box-sizing: border-box; background-color: transparent; color: rgb(64, 120, 192); text-decoration: none;">Alternatives considered</a>&nbsp;section for commentary on that discussion.</p><h2 class="" style="box-sizing: border-box; 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: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="user-content-motivation" class="anchor" href="https://github.com/DougGregor/swift-evolution/blob/generalized-naming/proposals/0000-generalized-naming.md#motivation" aria-hidden="true" style="box-sizing: border-box; background-color: transparent; color: rgb(64, 120, 192); text-decoration: none; display: inline-block; padding-right: 2px; margin-left: -18px; line-height: 1;"><span class="octicon octicon-link" style="box-sizing: border-box; font-weight: normal; font-size: 16px; line-height: 1; font-family: octicons; display: inline-block; text-rendering: auto; -webkit-font-smoothing: antialiased; -webkit-user-select: none; vertical-align: middle; visibility: hidden;"></span></a>Motivation</h2><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">It's fairly common in Swift for multiple functions or methods to have the same "base name", but be distinguished by parameter labels. For example,&nbsp;<code class="" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', 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>&nbsp;has three methods with the same base name&nbsp;<code class="" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', 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 class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', 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 class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">extension</span> UIView {
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">insertSubview</span>(view: UIView, at <span class="pl-smi" style="box-sizing: border-box;">index</span>: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span>)
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">insertSubview</span>(view: UIView, aboveSubview <span class="pl-smi" style="box-sizing: border-box;">siblingSubview</span>: UIView)
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">insertSubview</span>(view: UIView, belowSubview <span class="pl-smi" style="box-sizing: border-box;">siblingSubview</span>: UIView)
}</pre></div><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">When calling these methods, the argument labels distinguish the different methods, e.g.,</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', 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 class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>insertSubview(view, at: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">3</span>)
someView<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>insertSubview(view, aboveSubview: otherView)
someView<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>insertSubview(view, belowSubview: otherView)</pre></div><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; 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 class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', 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 class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> fn <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> someView<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>insertSubview <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// ambiguous: could be any of the three methods</span></pre></div><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">In some cases, it is possible to use type annotations to disambiguate:</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', 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 class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> fn: (UIView, <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span>) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> someView<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>insertSubview    <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// ok: uses insertSubview(_:at:)</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> fn: (UIView, UIView) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> someView<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>insertSubview <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// error: still ambiguous!</span></pre></div><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">To resolve the latter case, one must fall back to creating a closure:</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', 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 class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> fn: (UIView, UIView) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> { view, otherView <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">in</span>
  button<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>insertSubview(view, otherView)
}</pre></div><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; 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 class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', 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 class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">extension</span> UIButton {
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">var</span> currentTitle: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">String</span>? { <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">...</span> }
}

<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">var</span> fn: () <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">String</span>? <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> { () <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">in</span>
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">return</span> button<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>currentTitle
}</pre></div><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; 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 class="" style="box-sizing: border-box; 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: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="user-content-proposed-solution" class="anchor" href="https://github.com/DougGregor/swift-evolution/blob/generalized-naming/proposals/0000-generalized-naming.md#proposed-solution" aria-hidden="true" style="box-sizing: border-box; background-color: transparent; color: rgb(64, 120, 192); text-decoration: none; display: inline-block; padding-right: 2px; margin-left: -18px; line-height: 1;"><span class="octicon octicon-link" style="box-sizing: border-box; font-weight: normal; font-size: 16px; line-height: 1; font-family: octicons; display: inline-block; text-rendering: auto; -webkit-font-smoothing: antialiased; -webkit-user-select: none; vertical-align: middle; visibility: hidden;"></span></a>Proposed solution</h2><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; 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 class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', 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 class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">`try`</span>() <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Bool</span> { <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">...</span> }</pre></div><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">declares a function named&nbsp;<code class="" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', 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&nbsp;<code class="" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', 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>&nbsp;is a keyword. I propose to extend the back-tick syntax to allow compound Swift names (e.g.,&nbsp;<code class="" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', 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&nbsp;<code class="" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', 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 class="" style="box-sizing: border-box; padding: 0px 0px 0px 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><li class="" style="box-sizing: border-box;"><p class="" style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">Compound names can be written entirely within the back-ticks, e.g.,</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px;"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', 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 class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> fn <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> someView<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>`insertSubview(_:at:)`
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> fn1 <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> someView<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>`insertSubview(_:aboveSubview:)`</pre></div><p class="" style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">The same syntax can also refer to initializers, e.g.,</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px;"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', 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 class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> buttonFactory <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> UIButton<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>`<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">init</span>(type:)`</pre></div></li><li class="" style="box-sizing: border-box;"><p class="" style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">Getters and setters can be written using dotted syntax within the back-ticks:</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px;"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', 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 class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> specificTitle <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> button<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>`currentTitle<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">get</span>` <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// has type () -&gt; String?</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> otherTitle <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> UIButton<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>`currentTitle<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">get</span>`  <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// has type (UIButton) -&gt; () -&gt; String?</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> setTintColor <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> button<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>`tintColor<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">set</span>`     <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// has type (UIColor!) -&gt; ()</span></pre></div><p class="" style="box-sizing: border-box; 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 class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px;"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', 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 class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">extension</span> Matrix {
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">subscript</span> (row row: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Int</span>) <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> [<span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Double</span>] {
    <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">get</span> { <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">...</span> }
    <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">set</span> { <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">...</span> }
  }
}

<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> getRow <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> someMatrix<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>`<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">subscript</span>(row:)<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">get</span>` <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// has type (Int) -&gt; () -&gt; [Double]</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> setRow <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> someMatrix<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>`<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">subscript</span>(row:)<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">set</span>` <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// has type (Int) -&gt; ([Double]) -&gt; ()</span></pre></div><p class="" style="box-sizing: border-box; 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&nbsp;<code class="" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', 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>&nbsp;behavior of a property:</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px;"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', 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 class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">self</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>`myProperty<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">lazy</span>`<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>clear()</pre></div></li><li class="" style="box-sizing: border-box;"><p class="" style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">Base names that are meaningful keywords (<code class="" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', 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>&nbsp;and&nbsp;<code class="" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', 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 class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px;"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', 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 class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">extension</span> Font {
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">`subscript`</span>() <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> Font {
    <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// return the subscript version of the given font</span>
  }
}

<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> getSubscript <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> font<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>``<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">subscript</span>`()` <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// has type () -&gt; Font</span></pre></div></li></ul><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">The "produce the Objective-C selector for the given method" 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 class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', 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 class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> getter: Selector <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> objc_selector(NSDictionary<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>`<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">subscript</span>(_:)<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">get</span>`) <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// produces objectForKeyedSubscript:</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> setter: Selector <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> objc_selector(NSDictionary<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>`<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">subscript</span>(_:)<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">set</span>`) <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// produces setObject:forKeyedSubscript:</span></pre></div><h2 class="" style="box-sizing: border-box; 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: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="user-content-impact-on-existing-code" class="anchor" href="https://github.com/DougGregor/swift-evolution/blob/generalized-naming/proposals/0000-generalized-naming.md#impact-on-existing-code" aria-hidden="true" style="box-sizing: border-box; background-color: transparent; color: rgb(64, 120, 192); text-decoration: none; display: inline-block; padding-right: 2px; margin-left: -18px; line-height: 1;"><span class="octicon octicon-link" style="box-sizing: border-box; font-weight: normal; font-size: 16px; line-height: 1; font-family: octicons; display: inline-block; text-rendering: auto; -webkit-font-smoothing: antialiased; -webkit-user-select: none; vertical-align: middle; visibility: hidden;"></span></a>Impact on existing code</h2><p class="" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; 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 class="" style="box-sizing: border-box; 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: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="user-content-alternatives-considered" class="anchor" href="https://github.com/DougGregor/swift-evolution/blob/generalized-naming/proposals/0000-generalized-naming.md#alternatives-considered" aria-hidden="true" style="box-sizing: border-box; background-color: transparent; color: rgb(64, 120, 192); text-decoration: none; display: inline-block; padding-right: 2px; margin-left: -18px; line-height: 1;"><span class="octicon octicon-link" style="box-sizing: border-box; font-weight: normal; font-size: 16px; line-height: 1; font-family: octicons; display: inline-block; text-rendering: auto; -webkit-font-smoothing: antialiased; -webkit-user-select: none; vertical-align: middle; visibility: hidden;"></span></a>Alternatives considered</h2><ul class="" style="box-sizing: border-box; padding: 0px 0px 0px 2em; margin-top: 0px; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, 'Segoe UI', Arial, freesans, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255); margin-bottom: 0px !important;"><li class="" style="box-sizing: border-box;"><p class="" style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">Michael Henson&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/002168.html" class="" style="box-sizing: border-box; background-color: transparent; color: rgb(64, 120, 192); text-decoration: none;">proposed</a>&nbsp;naming getters and setters using&nbsp;<code class="" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', 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>&nbsp;syntax followed by&nbsp;<code class="" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', 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>&nbsp;or&nbsp;<code class="" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', 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 class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px;"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', 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 class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> specificTitle <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> button<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>currentTitle#<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">get</span></pre></div><p class="" style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">The use of postfix&nbsp;<code class="" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', 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>&nbsp;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&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/002210.html" class="" style="box-sizing: border-box; background-color: transparent; color: rgb(64, 120, 192); text-decoration: none;">here</a>. The proposals in that discussion actually included type annotations as well, but the syntax seems cleaner---and more directly focused on&nbsp;<em class="" style="box-sizing: border-box;">names</em>---without them, e.g.,:</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px;"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', 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 class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> fn <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> someView<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>insertSubview#(_:at:)</pre></div><p class="" style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">which works. I didn't go with this syntax because (1) it breaks up Swift method names such as&nbsp;<code class="" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', 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&nbsp;<code class="" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', 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>&nbsp;in the middle, and (2) while useful, this feature doesn't seem important enough to justify overloading&nbsp;<code class="" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', 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 class="" style="box-sizing: border-box;"><p class="" style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">Joe Groff&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151214/003008.html" class="" style="box-sizing: border-box; background-color: transparent; color: rgb(64, 120, 192); text-decoration: none;">notes</a>&nbsp;that&nbsp;<em class="" style="box-sizing: border-box;">lenses</em>&nbsp;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't address the general naming issue or the desire to retrieve the Objective-C selector for a getter/setter.</p></li><li class="" style="box-sizing: border-box;"><p class="" style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">Can we drop the back-ticks? It's very tempting to want to drop the back-ticks entirely, because something like</p><div class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px;"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', 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 class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> fn <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> someView<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>insertSubview(_:at:)</pre></div><p class="" style="box-sizing: border-box; margin-top: 16px; margin-bottom: 16px;">can be correctly parsed as a reference to&nbsp;<code class="" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', 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 class="highlight highlight-source-swift" style="box-sizing: border-box; margin-bottom: 16px;"><pre class="" style="box-sizing: border-box; overflow: auto; font-family: Consolas, 'Liberation Mono', 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 class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">extension</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Optional</span> {
  <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">func</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">get</span>() <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">-&gt;</span> T { <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">return</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">self</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">!</span> }
}

<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> fn1 <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> button<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>currentTitle<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">get</span>   <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// getter or Optional&lt;String&gt;.get?</span>
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">let</span> fn2 <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">set</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">.</span>removeAllElements()   <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// call or reference?</span></pre></div></li></ul><div class=""><br class=""></div></div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>- Doug</div><div class=""><br class=""></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" class="" style="height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;"></div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></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; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class=""><span class="Apple-converted-space">&nbsp;</span>_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">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; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><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; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">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; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><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; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></div></blockquote></div></body></html>