<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>I don't think this is a case where that rule applies, rather it seems like we're sliding back into Objective-C's approach of "stick a sentence into a selector". &nbsp;`map` for Arrays is not called `mapIterateApply`, map for Sets is not called `mapUnorderedIterateApply`, map for Dictionaries is not called `mapUnorderedIterateKeyValuePairsApply`. &nbsp;In every case, you are performing the same essential operation, so why not give them the same name? &nbsp;There is incredible power in being able to pin down a singular common concept and factor it out as Sequence has done. &nbsp;Moreso than not omitting needless words here in my opinion.</div><div><br></div><div>A certain, shall we say, controversial overload of `flatMap` is a different kettle of fish, though.</div><div><br><div>~Robert Widmann</div></div><div><br>2016/12/06 21:46、Jay Zhao &lt;<a href="mailto:zhaojianyin@icloud.com">zhaojianyin@icloud.com</a>&gt; のメッセージ:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=utf-8"><div class=""><div class=""><font size="2" class="">It applies in theory to think Optional as a collect of one and for that reason map is a perfect name.</font></div><div class=""><font size="2" class=""><br class=""></font></div><div class=""><font size="2" class="">But in practice, we often use the same variable name for <b class="">array</b> and <b class="">array?</b> . &nbsp;So when you see :</font></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-family: Helvetica; font-size: small;" class=""><span class="Apple-tab-span" style="white-space:pre">                </span>cars.</span><b style="font-family: Helvetica;" class="">map</b><span style="font-family: Helvetica; font-size: small;" class="">({...$0...}) &nbsp;</span></div></div><div class=""><font size="2" class="">You can not tell which map and even worse which $0 it is.</font></div><div class=""><font size="2" class=""><br class=""></font></div><div class=""><font size="2" class="">According to Swift API Design Guidelines&nbsp;<b class="">#1</b>,&nbsp;<strong style="box-sizing: border-box; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;" class="">Clarity at the point of use</strong>.&nbsp;</font></div><div class=""><span style="font-size: small;" class="">And to combine theory and practice, I propose </span><b class="">mapUnwrapped</b><span style="font-size: small;" class=""> to remove the confusion.</span></div><div class=""><font size="2" class=""><br class=""></font></div><div class=""><font size="2" class="">Actually this is what’s been adopted in my company:</font></div></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; min-height: 15px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(186, 45, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">public</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);" class=""> </span><span style="font-variant-ligatures: no-common-ligatures;" class="">extension</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">Optional</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);" class=""> {</span></div></div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">/// Pass the `Optional` into the closure that returns `Non-Optional`</span></div></div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">public</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> mapUnwrapped&lt;U&gt;(</span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">_</span><span style="font-variant-ligatures: no-common-ligatures" class=""> transform: (</span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Wrapped</span><span style="font-variant-ligatures: no-common-ligatures" class="">) </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">throws</span><span style="font-variant-ligatures: no-common-ligatures" class=""> -&gt; </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">U</span><span style="font-variant-ligatures: no-common-ligatures" class="">) </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">rethrows</span><span style="font-variant-ligatures: no-common-ligatures" class=""> -&gt; </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">U</span><span style="font-variant-ligatures: no-common-ligatures" class="">? {</span></div></div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">return</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">try</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">map</span><span style="font-variant-ligatures: no-common-ligatures" class="">(transform)</span></div></div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; }</span></div></div></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">}</span></div></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">To summary my idea:</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">This is the situation where usability &gt; design purity for a language(a tool).</div></blockquote></blockquote><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On 7 Dec 2016, at 08:05, Robert Widmann &lt;<a href="mailto:devteam.codafi@gmail.com" class="">devteam.codafi@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class="">If you think of Optional as a zero-or-one element collection there's really no reason this operation should be named any differently. &nbsp;It still lifts a function over values to one over Optionals. &nbsp;It still extracts the contents of the structure and applies the function (propagating failure if necessary). &nbsp;The operation is no different from the one required of a plain Sequence conformance, why should it have a new name if it is not a new operation?&nbsp;</div><div class=""><br class=""></div><div class=""><div class="">~Robert Widmann</div></div><div class=""><br class="">2016/12/05 22:46、Jay Zhao via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; のメッセージ:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><span style="font-size: 14px;" class="">Hi there,</span><div class=""><span style="font-size: 14px;" class=""><br class=""></span></div><div class=""><span style="font-size: 14px;" class="">Code explains everything:</span></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span></div></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><br class=""></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">/// Maybe a bad API naming in Swift? See below:</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">/// array1 can be array of any object that have a `count` method</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> array1 = [[</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span><span style="font-variant-ligatures: no-common-ligatures" class="">]]()</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> array2 :[</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span><span style="font-variant-ligatures: no-common-ligatures" class="">]? = </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">nil</span></div><div style="margin: 0px; line-height: normal; min-height: 15px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><br class="webkit-block-placeholder"></div><div style="margin: 0px; line-height: normal; min-height: 15px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><br class="webkit-block-placeholder"></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// I believe the confusion between `array.map` and `optionalArray.map` is really bad.</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// Because when you read code like this, you can not tell which is which:</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">_</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = array1.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">map</span><span style="font-variant-ligatures: no-common-ligatures" class="">({$0.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">count</span><span style="font-variant-ligatures: no-common-ligatures" class="">})</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">_</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = array2.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">map</span><span style="font-variant-ligatures: no-common-ligatures" class="">({$0.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">count</span><span style="font-variant-ligatures: no-common-ligatures" class="">})</span></div><div style="margin: 0px; line-height: normal; min-height: 15px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</span><br class="webkit-block-placeholder"></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// It can be clearer:</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// 1, we pass `self.element` into the closure</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">_</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = array1.</span><span style="font-variant-ligatures: no-common-ligatures; color: #3e1e81" class="">map</span><span style="font-variant-ligatures: no-common-ligatures" class="">({$0.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">count</span><span style="font-variant-ligatures: no-common-ligatures" class="">})</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">// 2, we pass self directly into the closure</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">_</span><span style="font-variant-ligatures: no-common-ligatures" class=""> = array2.</span><span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">mapMe</span><span style="font-variant-ligatures: no-common-ligatures" class="">({$0.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">count</span><span style="font-variant-ligatures: no-common-ligatures" class="">})</span></div></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">The mapFlat method is also problematic.</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Yours,</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Jay Zhao</span></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" 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></blockquote></div><br class=""></div></blockquote></body></html>