<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="">In this mail I’m answering several statements made in this thread by different people, not only Brent’s mail from which I just picked the following snippet:<div class=""><br class=""><div><blockquote type="cite" class=""><div class=""><span style="font-family: Helvetica; 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; float: none; display: inline !important;" class="">let names = people.map =&gt; person { person.name }</span></div></blockquote><br class=""></div><div>For me that is more difficult to read than</div><div><br class=""></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>let names = people.map { person in person.name }</div><div><br class=""></div><div>Especially when chaining is used, i.e.</div><div><br class=""></div><div><span class="" style="display: inline !important;"><span class="Apple-tab-span" style="white-space:pre">        </span>let names = people.filter =&gt; person { person.isFriend }.map =&gt; person { person.name }</span></div><div><span class="" style="display: inline !important;"><br class=""></span></div><div><span class="" style="display: inline !important;">(or would I have to add parentheses somewhere with this proposed syntax?)</span></div><div><span class="" style="display: inline !important;"><br class=""></span></div><div><span class="" style="display: inline !important;">vs.</span></div><div><span class="" style="display: inline !important;"><br class=""></span></div><div><span class="" style="display: inline !important;"><span class="Apple-tab-span" style="white-space:pre">        </span>let names = people.filter { person in person.isFriend }.map { person in person.name }</span></div><div><span class="" style="display: inline !important;"><br class=""></span></div><div><span class="" style="display: inline !important;"><br class=""></span></div><div>Those „=&gt;“ pretty much&nbsp;visually&nbsp;separate the statement in the wrong positions, i.e. the parts grouped together visually are</div><div><span class="" style="display: inline !important;"><br class=""></span></div><div><span class="" style="display: inline !important;">1.&nbsp;</span>people.filter</div><div>2. person { person.isFriend }.map</div><div>3. person { person.name }</div><div><br class=""></div><div>which is simply wrong for the middle part (or parts in case of more chaining).</div><div><br class=""></div><div>Whereas having the arguments in the closure separate the parts visually much better, keeping the closures together and interspersed with the function names.</div><div><br class=""></div><div><br class=""></div><div>With regards to trailing closures: Having them is an important part of DSLs in Ruby, Smalltalk and Scala.</div><div><br class=""></div><div>See for example the links cited in <a href="https://news.ycombinator.com/item?id=7921011" class="">https://news.ycombinator.com/item?id=7921011</a> or the Akka library (<a href="http://akka.io" class="">http://akka.io</a>) or rake (Ruby’s „make" replacement).</div><div><br class=""></div><div>Of course Alexander is right that the concept of a trailing closure works only for one closure and not for several. That is indeed a thing where Smalltalk’s syntax without any parentheses around function arguments had a really nice advantage which is not possible in Swift (although the parameter keywords are really great in alleviating this).</div><div>But there are so many cases (as the links above demonstrate) where a single trailing closure is sufficient that this feature is tremendously useful.</div><div><br class=""></div><div><br class=""></div><div>With regards to Haskell: the above example would (typically) look like:</div><div><br class=""></div><div>names = map (\person -&gt; name person) . filter (\person -&gt; isFriend person) $ people</div><br class=""></div><div class="">which also uses only one pair of parentheses just around the lambda expressions (because Haskell has neither parentheses around parameters nor around closures).</div><div class=""><br class=""></div><div class="">Visually it actually looks just the same as Swift’s closures (replacing parentheses with braces and „-&gt;“ with „in“ and dropping the backslash which stands in for the greek letter lambda), i.e. visually the parameters of the closure are within the parentheses, just like in Swift.</div><div class="">Of course the syntactical meaning of the parentheses is different from that of the braces but the visual effect is quite important in my eyes. That helps a lot in readability.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">With regards to „in“: I personally like it but could also live with something like „=&gt;“ or the bar „|“ as used in Ruby (two bars around the params) or Smalltalk (just one bar after the params which I would prefer), e.g.</div><div class=""><br class=""></div><div class="">let names = people.map { person | person.name }</div><div class=""><br class=""></div><div class="">although the „in“ definitely looks better with syntax highlighting and when using the wrong font like now (where the bar just looks like the upper case letter „i“).</div><div class=""><br class=""></div><div class="">I think I said it already: the „in“ reminds me of the let-in-expression of Haskell, e.g. „let foo = 3 in …“</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">-Thorsten</div></body></html>