<div dir="ltr"><br style="font-size:14px"><span style="font-size:14px">func add2(_ pair: (Int, Int)) -&gt; Int {</span><br style="font-size:14px"><span style="font-size:14px">    return pair.0 + pair.1</span><br style="font-size:14px"><span style="font-size:14px">}</span><br><div><span style="font-size:14px"><br></span></div><div><span style="font-size:14px">consider the follows</span></div><div><br></div><span style="font-size:14px">let _add2 =  </span><span style="font-size:14px">add2     // </span><span style="font-size:14px">add2 have the typeof `((Int, Int)) -&gt; Int`, it should flatten to </span><span style="font-size:14px">`(Int, Int) -&gt; Int`</span><div><span style="font-size:14px"><br></span></div><div><span style="font-size:14px">so these two lines are also acceptable</span></div><div><span style="font-size:14px">[(1, 2)].map(add1)</span><br style="font-size:14px"><span style="font-size:14px">[(1, 2)].map(add2)</span><span style="font-size:14px"><br></span></div><div><span style="font-size:14px"><br></span></div><div><span style="font-size:14px">this proposal is not just changing the behaviour of closure, this proposal also changing the tuple type</span></div><div><span style="font-size:14px"><br></span></div><div><span style="font-size:14px">(((Int, Int)))   flatten to   (Int, Int)</span></div><div><span style="font-size:14px">(Int, </span><span style="font-size:14px">(((Int, Int))), Int</span><span style="font-size:14px">)</span><span style="font-size:14px">   flatten to   </span><span style="font-size:14px">(Int, </span><span style="font-size:14px">(Int, Int)</span><span style="font-size:14px">, Int)</span></div><div><span style="font-size:14px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-06-07 12:03 GMT+08:00 Stephen Celis <span dir="ltr">&lt;<a href="mailto:stephen.celis@gmail.com" target="_blank">stephen.celis@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The inline cases make sense to me, but my concern for ambiguity are because we can define both of these functions:<br>
<br>
    func add1(_ x: Int, _ y: Int) -&gt; Int {<br>
      return x + y<br>
    }<br>
    func add2(_ pair: (Int, Int)) -&gt; Int {<br>
      return pair.0 + pair.1<br>
    }<br>
<br>
    // What&#39;s the behavior here?<br>
    [(1, 2)].map(add1)<br>
    [(1, 2)].map(add2)<br>
<br>
What comes to mind, though, is, Swift already prevents single-element tuples, so why not prevent functions that take a single tuple as the only argument?<br>
<br>
Swift could provide a fix-it for functions that take single tuples and say: &quot;Swift functions cannot take a single tuple. Please write a function that takes as many arguments as the tuple specified.&quot;<br>
<br>
Considering the fact that Swift generally operates in a multi-argument world, and given that functions taking a single tuple are the minority, I think this would be a good way to move forward.<br>
<span class="HOEnZb"><font color="#888888"><br>
Stephen<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
&gt; On Jun 6, 2017, at 11:21 PM, Susan Cheng &lt;<a href="mailto:susan.doggie@gmail.com">susan.doggie@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;  [(1, 2)].map({ x, y in x + y })  // this line is correct<br>
&gt;  [(1, 2)].map({ tuple in tuple.0 + tuple.1 })  // this line should not accepted<br>
&gt;<br>
&gt; or<br>
&gt;<br>
&gt;  [(1, 2)].map({ $0 + $1 })  // this line is correct<br>
&gt;  [(1, 2)].map({ $0.0 + $0.1 })  // this line should not accepted<br>
&gt;<br>
&gt; it&#39;s because `((Int, Int)) -&gt; Int` always flatten to `(Int, Int) -&gt; Int`<br>
&gt; so, it should only accept the function with two arguments<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; 2017-06-07 11:07 GMT+08:00 Stephen Celis &lt;<a href="mailto:stephen.celis@gmail.com">stephen.celis@gmail.com</a>&gt;:<br>
&gt; I like this a lot, but how do we solve for the function case?<br>
&gt;<br>
&gt;     func add(_ x: Int, _ y: Int) -&gt; Int {<br>
&gt;       return x + y<br>
&gt;     }<br>
&gt;     [(1, 2)].map(add)<br>
&gt;<br>
&gt; Where does `map` with a function of `((Int, Int)) -&gt; Int` fit in?<br>
&gt;<br>
&gt; &gt; On Jun 6, 2017, at 10:15 PM, Susan Cheng via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt; &gt;<br>
&gt; &gt; Introduction<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; Because the painful of SE-0110, here is a proposal to clarify the tuple syntax.<br>
&gt; &gt;<br>
&gt; &gt; Proposed solution<br>
&gt; &gt;<br>
&gt; &gt; 1. single element tuple always be flattened<br>
&gt; &gt;<br>
&gt; &gt; let tuple1: (((Int))) = 0  // TypeOf(tuple1) == Int<br>
&gt; &gt;<br>
&gt; &gt; let tuple2: ((((Int))), Int) = (0, 0)  // TypeOf(tuple2) == (Int, Int)<br>
&gt; &gt;<br>
&gt; &gt; 2. function arguments list also consider as a tuple, which means the function that accept a single tuple should always be flattened.<br>
&gt; &gt;<br>
&gt; &gt; let fn1: (Int, Int) -&gt; Void = { _, _ in }<br>
&gt; &gt;<br>
&gt; &gt; let fn2: ((Int, Int)) -&gt; Void = { _, _ in }  // always flattened<br>
&gt; &gt;<br>
&gt; &gt; let fn3: (Int, Int) -&gt; Void = { _ in }  // not allowed, here are two arguments<br>
&gt; &gt;<br>
&gt; &gt; let fn4: ((Int, Int)) -&gt; Void = { _ in }  // not allowed, here are two arguments<br>
&gt; &gt;<br>
&gt; &gt; ______________________________<wbr>_________________<br>
&gt; &gt; swift-evolution mailing list<br>
&gt; &gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt; &gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
&gt;<br>
&gt;<br>
<br>
</div></div></blockquote></div><br></div>