<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="">While I know it might be a bit strange to have different rules for each side, I think I prefer empty brackets on the left and Void on the right, but in combination with required parenthesis on the left. So we’d have:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>() -> Void<span class="Apple-tab-span" style="white-space:pre">                </span>// yes</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>Void -> ()<span class="Apple-tab-span" style="white-space:pre">                </span>// no</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>() -> ()<span class="Apple-tab-span" style="white-space:pre">                </span>// no (rhs interpreted as empty tuple which is not allowed)</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>() -> Int<span class="Apple-tab-span" style="white-space:pre">                </span>// yes</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>Int -> Void<span class="Apple-tab-span" style="white-space:pre">        </span>// no (lhs no parens)</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>(Int) -> Void<span class="Apple-tab-span" style="white-space:pre">        </span>// yes</div><div class=""><br class=""></div><div class="">I think the parenthesis helps to highlight that it’s a function/closure, I think it’s also clearer for cases like:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>((Int, String)) -> Void<span class="Apple-tab-span" style="white-space:pre">        </span>// this is a closure taking a two-part tuple</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>(Int, String) -> Void<span class="Apple-tab-span" style="white-space:pre">                </span>// this is definitely a closure taking an Int and a String</div><br class=""><div><blockquote type="cite" class=""><div class="">On 23 Apr 2016, at 11:47, Антон Жилин 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=""><blockquote style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex" class="gmail_quote"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;white-space:normal" class="">Therefore the impermissible:<br class=""></span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;white-space:normal" class="">(()) -> ()</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;white-space:normal" class=""> </span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;white-space:normal" class="">Is identical to:<br class=""></span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;white-space:normal" class="">(Void) -> ()</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;white-space:normal" class=""> </span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;white-space:normal" class="">So to follow these rules, it must instead be:<br class=""></span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;white-space:normal" class="">Void -> ()</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;white-space:normal" class=""> </span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;white-space:normal" class="">… and we’re back to T1 -> T2 </span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;white-space:normal" class=""></span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;white-space:normal" class="">:</span><i style="color:rgb(34,34,34);font-family:arial,sans-serif;white-space:normal" class=""> )</i></blockquote><pre style="white-space: pre-wrap;" class=""><font face="arial, helvetica, sans-serif" class=""><br class=""></font></pre><pre style="white-space: pre-wrap;" class=""><font face="arial, helvetica, sans-serif" class="">Wrong! If we enforce parentheses in function types, we won't be able to write</font></pre><pre style="" class=""><font class=""><span style="white-space:pre-wrap" class="">Void -> ()<br class=""></span></font></pre><pre style="white-space: pre-wrap;" class=""><font face="arial, helvetica, sans-serif" class="">Parentheses will be required on the grammar level. The correct way to write this will be:</font></pre><pre style="white-space: pre-wrap;" class=""><pre style="white-space:pre-wrap" class="">() -> () or () -> Void</pre><pre style="white-space:pre-wrap" class=""><font face="arial, helvetica, sans-serif" class="">The following will be legal:</font></pre><pre style="white-space:pre-wrap" class=""><font face="monospace, monospace" class="">(Void) -> () and (()) -> ()</font></pre><pre style="white-space:pre-wrap" class=""><font face="arial, helvetica, sans-serif" class="">It is a function that takes a single parameter </font><font face="monospace, monospace" class="">()</font><font face="arial, helvetica, sans-serif" class=""> and returns </font><font face="monospace, monospace" class="">()</font><font face="arial, helvetica, sans-serif" class="">.</font></pre><pre style="white-space:pre-wrap" class=""><font face="arial, helvetica, sans-serif" class="">I additionally propose that the following should be illegal, because additional parentheses aren't needed there:</font></pre><pre style="white-space:pre-wrap" class=""><font face="monospace, monospace" class="">((())) -> () and () -> (()) and just (Int) and (())</font></pre><pre style="white-space:pre-wrap" class=""><font face="arial, helvetica, sans-serif" class="">Hope it cleared up things a little bit.</font></pre><pre style="white-space:pre-wrap" class=""><font face="arial, helvetica, sans-serif" class="">- Anton</font></pre></pre></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>