<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">FWIW, the way I would design this API would be:</div><div class=""><br class=""></div><div class=""> accountStore.findAccount(“abcdef”)</div><div class=""><br class=""></div><div class="">Having the method start with a verb definitely helps clarify what it actually does, and avoids any potential noun/verb confusion, or confusion between finding or creating a record. But that’s a (potential) issue in the API itself, not the translation. `accountWithIdentifier(_:)`, `account(identifier:)` and `account(_:)` share this, and I don’t see how the first one would be any clearer just because it has “WithIdentifier” in the name.</div><br class=""><div class="">
<div class="">— Radek</div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On 28 Jan 2016, at 22:09, Jacob Bandes-Storch 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" class="">"account" is also a verb. It's not easy to confuse in this situation, but I fear other verb/noun ambiguities might be more confusing; the preposition helps.<div class="gmail_extra"><br clear="all" class=""><div class=""><div class="gmail_signature"><div dir="ltr" class=""><div class="">Jacob<br class=""></div></div></div></div>
<br class=""><div class="gmail_quote">On Thu, Jan 28, 2016 at 12:03 PM, Jordan Rose via swift-evolution <span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">Y'know, I was going to complain about this too, and wrote up an example, complete with call site…</div><div class=""><br class=""></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px" class=""><div class="">accountStore.account(currentID)</div></blockquote><div class=""><br class=""></div><div class="">…and then realized that it didn't bother me as much as I thought. "account" is a noun, so this is either getting or creating an account for me (as if it were a property), and it's going to use "currentID" to do it.</div><div class=""><br class=""></div><div class="">I'm very used to "fooWithBar: baz" meaning either "get me the foo that has a bar matching baz" or "create me a foo with its bar set to baz". But I'm not sure this new convention is any <i class="">worse</i>, now that the base name isn't assumed to include the first argument.</div><div class=""><br class=""></div><div class="">Jordan</div><div class=""><div class="h5"><div class=""><br class=""></div><br class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 28, 2016, at 0:51, David Hart via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:</div><br class=""><div class=""><div dir="auto" class=""><div class="">Loss of 'with' sounds weird in certain cases:</div><div class=""><br class=""></div><div class=""><pre style="word-wrap:break-word" class=""><font face="UICTFontTextStyleBody" class=""><span style="white-space:normal;background-color:rgba(255,255,255,0)" class="">- func account(identifier identifier: String!) -> ACAccount!</span></font></pre><pre style="word-wrap:break-word" class=""><span style="white-space:normal;background-color:rgba(255,255,255,0);font-family:UICTFontTextStyleBody" class="">+ func account(identifier: String!) -> ACAccount!</span></pre><br class="">Sent from my iPhone</div><div class=""><br class="">On 28 Jan 2016, at 00:31, Douglas Gregor via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 27, 2016, at 10:03 AM, Dave Abrahams via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:</div><br class=""><div 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" class=""><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" class="">on Wed Jan 27 2016, Matthew Johnson <</span><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" class="">swift-evolution@swift.org</a><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" class="">> wrote:</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" 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" class=""><blockquote type="cite" 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" class="">Doug,<br class=""><br class="">I think this change looks great! I don’t have time to look through<br class="">the full patch but did look through quite a bit. It adds clarity in<br class="">the vast majority of cases I looked at.<br class=""><br class="">It seems like with-as-separator is a good heuristic for determining<br class="">when the first parameter is not essential to a good name for the<br class="">fundamental operation. I agree with the comments earlier on that in<br class="">these cases a label for the first parameter is the best approach.<br class=""><br class="">I also really like that this groups methods with the same fundamental<br class="">operation into overload families where they previously had independent<br class="">names. This is a big win IMO.<br class=""><br class="">There is a first-parameter-is-an-ID pattern I noticed after this<br class="">change. I show a few examples here, but there are a lot more:<br class=""><br class="">- func trackWithTrackID(trackID: CMPersistentTrackID) -> AVAssetTrack?<br class="">+ func track(trackID trackID: CMPersistentTrackID) -> AVAssetTrack?<br class=""><br class="">- func trackWithTrackID(trackID: CMPersistentTrackID) -> AVFragmentedAssetTrack?<br class="">+ func track(trackID trackID: CMPersistentTrackID) -> AVFragmentedAssetTrack?<br class=""><br class="">- func trackWithTrackID(trackID: CMPersistentTrackID) -> AVCompositionTrack?<br class="">+ func track(trackID trackID: CMPersistentTrackID) -> AVCompositionTrack?<br class=""><br class="">- func discoverUserInfoWithUserRecordID(userRecordID: CKRecordID,<br class="">completionHandler: (CKDiscoveredUserInfo?, Error?) -> Void)<br class=""><br class="">+ func discoverUserInfo(userRecordID userRecordID: CKRecordID,<br class="">completionHandler: (CKDiscoveredUserInfo?, Error?) -> Void)<br class=""><br class="">The first argument label `trackID` seems like it repeats type<br class="">information without adding clarity. I think it would be better to<br class="">just use `id` here. It seems like a candidate for heuristics as well.<br class="">For example, if the type name ends in ID and the label is a suffix of<br class="">the type name we could just use `id`. This is a somewhat specific<br class="">pattern, but IDs are common enough that it might make sense.<br class=""></blockquote><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" class=""><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" class="">Actually I've been saying for a while that arguments called ID,</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" class=""><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" class="">identifier, and name should not be labelled at all in many cases. Think</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" class=""><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" class="">about it.</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" class=""></div></blockquote></div><div class=""><br class=""></div><div class="">Patch where the words “ID”, “Identifier”, and “Name” in a name are considered to match the type “String”:</div><div class=""><br class=""></div><div class=""></div></div></blockquote><blockquote type="cite" class=""><div class=""><id-identifier-name-match-string.patch></div></blockquote><blockquote type="cite" class=""><div class=""><div class=""></div><div class=""><br class=""></div><div class="">… and then extending the rule to zap first argument labels named “identifier”, “id”, or “name”:</div><div class=""><br class=""></div><div class=""></div></div></blockquote><blockquote type="cite" class=""><div class=""><id-identifier-name-no-first-arg-label.patch></div></blockquote><blockquote type="cite" class=""><div class=""><div class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">(I’m not sure which one of these you meant, or something different):</div><br class=""><div class=""><br class=""></div><div class=""><span style="white-space:pre-wrap" class="">        </span>- Doug</div><div class=""><br class=""></div></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" target="_blank" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></div><br class="">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br class=""></div></div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>