<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 <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> 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"> </span><span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span><span class="Apple-converted-space"> </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=""> should go in the base name rather than in a label:<br class=""><br class=""> <span class="Apple-converted-space"> </span>a.tracksHavingMediaType("Wax Cylinder") // yes<br class=""> <span class="Apple-converted-space"> </span>a.removeFirstTrackHavingMediaType("BetaMax") // yes<br class=""><br class=""> <span class="Apple-converted-space"> </span>a.tracks(mediaType: "Wax Cylinder") // no<br class=""> <span class="Apple-converted-space"> </span>a.removeFirstTrack(havingMediaType: "BetaMax") // no<br class=""><br class=""> [yes, we could use "With" instead of "Having", but it's more<br class=""> ambiguous]<br class=""><br class=""> Words that describe attributes of an instance *to be created* should<br class=""> go in argument labels, rather than the base name (for parity with<br class=""> initializers):<br class=""><br class=""> <span class="Apple-converted-space"> </span>AudioTrack(mediaType: "BetaMax") // initializer<br class=""> <span class="Apple-converted-space"> </span>trackFactory.newTrack(mediaType: "Wax Cylinder") // yes<br class=""><br class=""> <span class="Apple-converted-space"> </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. 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. Particularly since Swift encourages passing functions around as objects rather than using string selectors. #2 implies that the prepositional phrase will appear when *referencing* the method (vs. calling it):</div><div class=""><br class=""></div><div class=""> let ops = [</div><div class=""> self.removeFirstTrackHavingMediaType,</div><div class=""> self.addTrackWithMediaType</div><div class=""> self.populateTrackOperationsForMediaType</div><div class=""> self.play</div><div class=""> ]</div><div class=""><br class=""></div><div class="">vs.</div><div class=""><br class=""></div><div class=""> let ops = [</div><div class=""> self.removeFirstTrack</div><div class=""> self.addTrack</div><div class=""> self.populateTrackOperations</div><div class=""> self.play</div><div class=""> ]</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. 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=""> // Compile error: Invalid redeclaration of removeFirstTrack</div><div class=""> func removeFirstTrack(havingMediaType: String) { ... }</div><div class=""> func removeFirstTrack(named: String) { ... }</div><div class=""> func removeFirstTrack(byArtist: String) { ... }</div><div class=""><div class=""><br class=""> // Compile error only when the function is referenced</div><div class=""> func removeTrack(n: Int, named: String)</div><div class=""> func removeTrack(n: Int, byArtist: String)</div><div class=""> let f = self.removeTrack // named: or byArtist:?</div></div><div class=""><br class=""></div><div class=""> // Legal...</div><div class=""> func removeFirstTrackHavingMediaType(_: String) { ... }</div><div class=""> func removeFirstTrackNamed(_: String) { ... }</div><div class=""> 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. 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> self.removeFirstTrack(mediaType:),</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span> self.addTrack(mediaType:),</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span> self.populateTrackOperationsForMediaType,</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span> 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>