<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 2, 2016, at 12:48 PM, Jarod Long 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 style="font-family: HelveticaNeue; 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="">This is definitely more clear when you completely separate these lines from their context, but code isn't written or read in complete isolation like this, so I think these examples significantly exaggerate the ambiguity of the pattern in the real world.</div><div style="font-family: HelveticaNeue; 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=""><br class=""></div><div style="font-family: HelveticaNeue; 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="">Even if you only make the minor change of renaming p to proximity (which is really what it should be), the first example becomes pretty clear:</div><div style="font-family: HelveticaNeue; 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=""><br class=""></div><div style="font-family: HelveticaNeue; 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=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class=""><span class="" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; line-height: 20px; white-space: pre-wrap; background-color: rgb(247, 247, 247);">let next = current.updating(proximity</span><span class="" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; line-height: 20px; white-space: pre-wrap; background-color: rgb(247, 247, 247);">)</span></div></div></blockquote></div><div style="font-family: HelveticaNeue; 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=""><br class=""></div></div></blockquote><div><br class=""></div><div>I just want to comment on this as I keep seeing this for arguments on the lists. APIs themselves should not be relying on well named inputs into them to create clear API signatures.</div><div><br class=""></div><div><div>The following version of the API is significantly more clear with no requirement of the variable names to be matched to the expectations of the API signature:</div><div class=""><br class=""></div></div><div><div class="" style="font-family: HelveticaNeue;"><div dir="ltr" class=""><div class=""><span class="" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; line-height: 20px; white-space: pre-wrap; background-color: rgb(247, 247, 247);">let next = current.updating(proximity: p</span><span class="" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; line-height: 20px; white-space: pre-wrap; background-color: rgb(247, 247, 247);">)</span></div></div></div></div><div><br class=""></div><div>Similarly,</div><div><br class=""></div><div><div class=""><div dir="ltr" class=""><div class=""><div class=""><span class="" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; line-height: 20px; white-space: pre-wrap; background-color: rgb(247, 247, 247);">let content = listItemView.text.trimming(characters: .</span><span class="" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; line-height: 20px; white-space: pre-wrap; background-color: rgb(247, 247, 247);">whitespaceAndNewlines)</span></div></div></div></div></div><div><br class=""></div><div>At least I have some context at the call site what the purpose of .whitespaceAndNewlines.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="font-family: HelveticaNeue; 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="">Ultimately, I don't think this is a very difficult pattern to learn. Maybe the first handful of times you see it you'll need to read the documentation to know exactly what it's doing, but once you've seen it a few times, it's an instantly recognizable pattern. If you see a gerund method, it returns a new thing by doing the verb to the thing. Is it worth the redundancy and noise to save new developers from possibly needing to look at a method's documentation a few times?</div></div></blockquote></div><div class=""><br class=""></div>I really do not like the -ing form; it reads backwards. I intuitively expected the object of the “trimming” to be the parameters, not the instance invoking the method.<div class=""><br class=""></div><div class=""><div><div class=""><div dir="ltr" class=""><div class=""><div class=""><span class="" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; line-height: 20px; white-space: pre-wrap; background-color: rgb(247, 247, 247);">let content = listItemView.text.trimmed(characters: .</span><span class="" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; line-height: 20px; white-space: pre-wrap; background-color: rgb(247, 247, 247);">whitespaceAndNewlines)</span></div><div class=""><span class="" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 14px; line-height: 20px; white-space: pre-wrap; background-color: rgb(247, 247, 247);"><br class=""></span></div></div></div></div></div><div class="">Whereas when I read the above, it’s natural to read that the "text is trimmed with” the parameter set. The former is, “the text is trimming with” the parameter set.</div><div class=""><br class=""></div><div class="">-David</div><div class=""><br class=""></div></div></body></html>