<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><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">For clarity's sake, there's really two syntactic issues that I think would be good to address. The first, which I think is the far bigger problem, which is that right now a list of params with closures is very hard to read. For example, this requires mental effort to decode whether this is returning an Int, or a closure returning an Int:<div class=""><br class=""></div><div class=""><pre style="white-space:pre-wrap;color:rgb(80,0,80);font-size:12.8px" class=""><font face="monospace, monospace" class=""><span style="white-space:normal" class="">func makeIncrementer(forIncrement amount: Int) -&gt; () -&gt; Int {</span></font></pre><pre style="white-space:pre-wrap;color:rgb(80,0,80);font-size:12.8px" class="">}</pre></div></div></div></div></blockquote>I look at currying like a right-associative operator (like the ternary operator, or assignments in languages like C). There is a function that takes no arguments and returns an int, that you get from a function that takes an int argument.</div><div><br class=""></div><div>Changing this to say</div><div><blockquote type="cite" class=""><div dir="ltr" class=""><div class=""><div class=""><pre class="" style="white-space: pre-wrap; color: rgb(80, 0, 80); font-size: 12.8px;"><font face="monospace, monospace" class="">func makeIncrementer(forIncrement amount: Int) -&gt; func () -&gt; Int {</font></pre></div></div></div></blockquote><div>feels like it is changing the behavior to that of a non-associative operator.&nbsp;</div><div><br class=""></div><div>One interesting result would be if by removing the ternary operator as it stands today and changing how currying heppens, swift wound up having no right associative operators left in core.</div><div><blockquote type="cite" class=""><div dir="ltr" class=""><div class=""><div class=""></div></div></div></blockquote></div><blockquote type="cite" class=""><div dir="ltr" class=""><div class=""><div class=""><pre style="white-space:pre-wrap;color:rgb(80,0,80);font-size:12.8px" class=""><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;white-space:normal" class="">And the second being that stylistically, having the params on the inside of the closure is breaking precedent of params outside of the block of code without gaining much.&nbsp;</span><br class=""></pre><pre style="white-space:pre-wrap;color:rgb(80,0,80);font-size:12.8px" class=""><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;white-space:normal" class="">Perhaps we could adopt the Obj-C ^ as a closure indicator. I think with existing Swift syntax, a lot of the confusion that caused <a href="http://www.fuckingblocksyntax.com/" class="">www.fuckingblocksyntax.com</a> would be avoided.</span><br class=""></pre><pre style="white-space:pre-wrap;color:rgb(80,0,80);font-size:12.8px" class=""></pre></div></div></div></blockquote><div>&lt;snip&gt;</div><blockquote type="cite" class=""><div dir="ltr" class=""><div class=""><div class=""><pre style="white-space:pre-wrap;color:rgb(80,0,80);font-size:12.8px" class=""><span style="font-family: monospace, monospace; font-size: 12.8px;" class="">makeIncrementer(forIncrement: ^(number: Int) {</span></pre><pre style="" class=""><pre style="color:rgb(80,0,80);font-size:12.8px;white-space:pre-wrap" class=""><span style="white-space:normal;font-family:monospace,monospace;font-size:12.8px" class="">&nbsp; &nbsp;if (number == 3) { return true }</span></pre><pre style="color:rgb(80,0,80);font-size:12.8px;white-space:pre-wrap" class=""><span style="white-space:normal;font-family:monospace,monospace;font-size:12.8px" class="">})</span></pre></pre></div></div></div></blockquote><div>Why does the block now have to be declared within the function parameters?</div><div>Why do I have to declare the type of number now?</div><div>Why do I *not* have to declare the return type as being a boolean?</div><div>Would this syntax still support single expression implicit returns, e.g. current Swift</div><div><br class=""></div></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div><div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&gt; [1,2,3].map() { number in number == 3 }</div></div></div><div><div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(52, 187, 199);" class="">$R0: [Bool] = 3 values {</div></div></div><div><div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(52, 187, 199);" class="">&nbsp; [0] = false</div></div></div><div><div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(52, 187, 199);" class="">&nbsp; [1] = false</div></div></div><div><div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(52, 187, 199);" class="">&nbsp; [2] = true</div></div></div><div><div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(52, 187, 199);" class="">}</div></div></div></blockquote><div><blockquote type="cite" class=""><div dir="ltr" class=""><div class=""><div class=""><pre style="white-space:pre-wrap;color:rgb(80,0,80);font-size:12.8px" class="">By having ^ mark an upcoming closure, I think it's a lot easier to follow what's going on with declarations because as you read left to right, you're prepped that a closure syntax is coming up as you read left to right. It also allows you to keep the params outside of the closure, which I think is a win. Closure params would also have the same syntax everywhere, and be extremely similar to normal method calls which would be easier for new Swift users. </pre></div></div></div></blockquote><div>There are three pieces at play here IMHO:</div><div>1. How functions (global and on types) are declared and implemented</div><div>2. How function specifications are indicated as types</div><div>3. How anonymous functions are declared and implemented</div><div><div class=""><div><br class=""></div><div>When I declare a global or type-specific function, I can specify its name and arguments, assign external names to them (as well as internal names), and declare my return value. The types, even if generic, must be known for the function implementation to pass semantic checks.</div><div><br class=""></div><div>The syntax for functions as types are really just a list of input and output types. There are not (for instance) named parameter requirements on the implementing functions. But the input and return types must be known to declare a new function type.</div><div><br class=""></div><div>Anonymous functions assume a great deal of type information from the context in which they are used. This is why you can get away with not declaring input types or even input names (using $0, $1, etc), the return type or even if a value is returned. The code is mapped into the context it is needed, then semantic evaluation is done.</div></div></div><div><br class=""></div>You are attempting to change #2 and #3 at the same time, when really they have quite different needs. I assume the reason anonymous functions (aka closures in Swift) have their argument names on the inside of the block is because the argument names have no external bearing whatsoever. Considering I may or may not declare type information or even give all the parameters names, this makes a certain kind of sense. If you were to move the argument names outside the block, you would need a syntax specifically for that. There are enough options that reusing the same base syntax between 1 and 3 or 2 and 3 would likely just _feel_ wrong.</div><div><br class=""></div><div>There are enough rules about escape analysis to possibly make sense to have function blocks, do blocks, repeat blocks, switch blocks, for…in blocks, etc all be considered ‘kinds’ of blocks, and for closure blocks to be on that list. It possibly makes sense for them to have a keyword just like all the other blocks to simplify compiler and human visual parsing. But I don’t envy the effort of redesigning and redecorating that particular bike shed :-)</div><div><br class=""></div><div>-DW</div></body></html>