<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 2, 2016, at 10:17 PM, Jonathan Tang 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 dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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=""><div class="gmail_extra"><br class="Apple-interchange-newline"><br class=""><div class="gmail_quote">On Tue, Feb 2, 2016 at 4:32 PM, Dave Abrahams via swift-evolution<span class="Apple-converted-space">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span><span class="Apple-converted-space">&nbsp;</span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><br class=""></blockquote><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">2. Words that describe attributes of an *already-existing* instance<br class="">&nbsp; &nbsp;should go in the base name rather than in a label:<br class=""><br class="">&nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span>a.tracksHavingMediaType("Wax Cylinder")&nbsp; &nbsp; &nbsp; // yes<br class="">&nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span>a.removeFirstTrackHavingMediaType("BetaMax") // yes<br class=""><br class="">&nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span>a.tracks(mediaType: "Wax Cylinder")&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // no<br class="">&nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span>a.removeFirstTrack(havingMediaType: "BetaMax") // no<br class=""><br class="">&nbsp; &nbsp;[yes, we could use "With" instead of "Having", but it's more<br class="">&nbsp; &nbsp;ambiguous]<br class=""><br class="">&nbsp; &nbsp;Words that describe attributes of an instance *to be created* should<br class="">&nbsp; &nbsp;go in argument labels, rather than the base name (for parity with<br class="">&nbsp; &nbsp;initializers):<br class=""><br class="">&nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span>AudioTrack(mediaType: "BetaMax")&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// initializer<br class="">&nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span>trackFactory.newTrack(mediaType: "Wax Cylinder")&nbsp; &nbsp;// yes<br class=""><br class="">&nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span>trackFactory.newTrackWithMediaType("Wax Cylinder") // no<br class=""><br class=""></blockquote><div class=""><br class=""></div><div class="">Very mixed feelings on this, probably adding up to a +0.2 or so.&nbsp; I'll mention a couple concerns that I haven't seen anyone raise:</div><div class=""><br class=""></div><div class="">Please consider the first-class function case when naming.&nbsp; Particularly since Swift encourages passing functions around as objects rather than using string selectors. &nbsp;#2 implies that the prepositional phrase will appear when *referencing* the method (vs. calling it):</div><div class=""><br class=""></div><div class="">&nbsp; let ops = [</div><div class="">&nbsp; &nbsp; self.removeFirstTrackHavingMediaType,</div><div class="">&nbsp; &nbsp; self.addTrackWithMediaType</div><div class="">&nbsp; &nbsp; self.populateTrackOperationsForMediaType</div><div class="">&nbsp; &nbsp; self.play</div><div class="">&nbsp; ]</div><div class=""><br class=""></div><div class="">vs.</div><div class=""><br class=""></div><div class="">&nbsp; let ops = [</div><div class="">&nbsp; &nbsp; self.removeFirstTrack</div><div class="">&nbsp; &nbsp; self.addTrack</div><div class="">&nbsp; &nbsp; self.populateTrackOperations</div><div class="">&nbsp; &nbsp; self.play</div><div class="">&nbsp; ]</div><div class=""><br class=""></div><div class="">The second option wins on verbosity, but the first arguably gives more clarity as to what the methods actually do.&nbsp; Also, the second has a potentially annoying semantic problem: if you have overloads for these methods that differ only in keyword, Swift won't be able to disambiguate them:</div><div class=""><br class=""></div><div class="">&nbsp; // Compile error: Invalid redeclaration of removeFirstTrack</div><div class="">&nbsp; func removeFirstTrack(havingMediaType: String) { ... }</div><div class="">&nbsp; func removeFirstTrack(named: String) { ... }</div><div class="">&nbsp; func removeFirstTrack(byArtist: String) { ... }</div><div class=""><div class=""><br class="">&nbsp; // Compile error only when the function is referenced</div><div class="">&nbsp; func removeTrack(n: Int, named: String)</div><div class="">&nbsp; func removeTrack(n: Int, byArtist: String)</div><div class="">&nbsp; let f = self.removeTrack &nbsp; // named: or byArtist:?</div></div><div class=""><br class=""></div><div class="">&nbsp; // Legal...</div><div class="">&nbsp; func removeFirstTrackHavingMediaType(_: String) { ... }</div><div class="">&nbsp; func removeFirstTrackNamed(_: String) { ... }</div><div class="">&nbsp; func removeFirstTrackByArtist(_: String) { ... }</div><div class=""><br class=""></div><div class="">Unless the Swift compiler were to change to make the former set legal, I think this is a powerful argument in favor of this proposal, because otherwise you may find that the compiler prevents you from writing the code that the guidelines encourage.&nbsp; You might also find that changing the type of an overload means you have to change the name to prevent a collision, which could be very surprising to users.</div></div></div></div></div></blockquote><br class=""></div><div>I suspect that you missed SE-0021:</div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">        </span><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0021-generalized-naming.md" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0021-generalized-naming.md</a></div><div><br class=""></div><div>which lets you name the arguments in a function reference, e.g:</div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>let f = self.removeTrack(_:named:)</div><div><div><span class="Apple-tab-span" style="white-space: pre;">        </span>let f2 = self.removeTrack(_:byArtist:)</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let ops = [</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp; self.removeFirstTrack(mediaType:),</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp; self.addTrack(mediaType:),</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp; self.populateTrackOperationsForMediaType,</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp; self.play</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>]</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span></div></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>- Doug</div><div><br class=""></div><br class=""></body></html>