<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Agreed, -1, I actually prefer using $0, $1, etc. </div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">Myles<br><br>Sent from my iPhone</div><div><br>On Feb 14, 2016, at 6:04 PM, Howard Lovatt via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">Sorry, not keen. Too much overlap with labels, therefore not worth the addition.</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"> -- Howard.<br></div></div>
<br><div class="gmail_quote">On 14 February 2016 at 07:38, Eugene Gubin via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Right now Swift provides shorthand argument names ($0, $1 etc) by default which could be overriden with more specific names. I think it would be nice to define our own default names as part of type definition:<br></div><div><br></div><div>typealias Closure = (first one: String, second two: String) -> Void</div><div><br></div><div>func executeClosure(closure: Closure) {</div><div><span style="white-space:pre-wrap">        </span>// the caller uses external parameter names, nothing changed here </div><div><span style="white-space:pre-wrap">        </span>closure(first: "first", second: 2)</div><div>}</div><div><br></div><div>executeClosure {</div><div><span style="white-space:pre-wrap">        </span>// the callee uses custom arguments instead of $0, $1</div><div><span style="white-space:pre-wrap">        </span>// also it is possible to override these names here as usual </div><div><span style="white-space:pre-wrap">        </span>print("one \(one) two \(two)")</div><div>}</div><div><br></div><div>This feature is backward compatible in that way what both</div><div><br></div><div>typealias Closure = (first: String, second: String) -> Void </div><div><br></div><div>and</div><div><br></div><div>typealias Closure = (String, String) -> Void</div><div><br></div><div>will provide the same behavior like now.</div><div><br></div><div>Possible applications: providing default argument names more meaningfull than $0, $1, DSL-like constructions.</div><div><br></div><div>Possible problem: names could overlap. Nothing new. $0, $1 could overlap too. Override argument names or variable names in a scope.</div></div>
<br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>