<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, May 29, 2017 at 3:18 PM, Vladimir.S <span dir="ltr"><<a href="mailto:svabox@gmail.com" target="_blank">svabox@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On 29.05.2017 21:08, Nevin Brackett-Rozinsky wrote:</span><span class="gmail-">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
barTuple{ (x, y) in } // valid, destructuring one tuple<br>
barTuple{ ((x, y)) in } // valid, destructuring one tuple with optional parentheses<br>
</blockquote>
<br></span>
Here is the problem for me. According to SE-0066 closure declared as {(x,y) in} should be of type (Int,Int)->() and not ((Int,Int))->().<br>
Why do you want to be able to pass wrong function/closure type into barTuple?</blockquote><div><br></div><div> I don’t.</div><div><br></div><div>I want the compile to infer from context whether “{ (x, y) in }” is of type “(_, _) -> _” with the optional parentheses included, or of type “((_, _)) -> _” with the optional parentheses elided. This is similar to how we use context to determine whether “1” is of type Int or Double or something else entirely.</div><div><br></div><div>If a closure appears in a context where it can only accept a tuple, such as mapping a dictionary, then obviously its type should have a tuple parameter. If a closure appears in a context where it can only accept two arguments, then obviously its type should have two parameters.</div><div><br></div><div>I want the compiler to figure out, when possible from context, whether the optional parentheses were included, so it “just works” for developers.</div><div><br></div><div>Nevin</div><div><br></div></div></div></div>