<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 4, 2016, at 9:21 AM, Erica Sadun via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">SE-0111 established that Swift's type system would not allow function argument labels to be expressed as part of a function type. As I've been working with curried functions, I'm discovering an unintended consequence of this proposal in that it strips curried functions of their external labels and the resulting calls of their readability.<div class=""><br class=""></div><div class="">```</div><div class=""><div class=""><font face="Menlo" class="">public func projected(</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; function f: @escaping (CGFloat) -&gt; CGFloat) -&gt;</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; (_ p0: CGPoint, _ p1: CGPoint) -&gt;&nbsp;</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; (_ percent: CGFloat) -&gt; CGPoint</font></div><div class=""><font face="Menlo" class="">{</font></div></div><div class="">```</div><div class=""><br class=""></div><div class="">Calling the first level of currying still reads acceptably:</div><div class=""><br class=""></div><div class="">```</div><div class=""><font face="Menlo" class="">let projectedFunction = projected(function: fToApply)</font></div><div class="">```</div><div class=""><br class=""></div><div class="">But after that, the enforced label-less arguments mean all further semantics have to stay within the name of the assigned partially applied function symbol and all arguments must be supplied without meaning, which is not in the spirit of API guidelines or under the umbrella of Swiftiness:</div><div class=""><br class=""></div><div class="">```</div><div class=""><font face="Menlo" class="">let fixedFunction = projectedFunction(p0, p1)</font></div><div class=""><font face="Menlo" class="">let value = fixedFunction(0.2)</font></div><div class="">```</div><div class=""><br class=""></div><div class="">There's no way to give either the line segment start and end points or the percent-of-progress arguments any labels. &nbsp;Further, Xcode/QuickHelp does not provide any support for documenting the roles of each curried return type.</div><div class=""><br class=""></div><div class="">Could this be addressed specifically for currying or has the boat sailed forever on this topic?</div><div class=""><br class=""></div></div></div></blockquote><div><br class=""></div><div>This could be expressed by allowing local variable names to have compound names when of function type. I would not require it to be expressed this way, but it would be a nice addition. This would look something like the following:</div><div><br class=""></div><div>let projectedFunction(from:to:) = projected(function: fToApply)</div><div>let scale(by:) = projectedFunction(from: myPoint1, to: myPoint2)</div><div>let finalPoint = scale(by: 3.0)</div><div><br class=""></div><div>When it comes to local assignment, it makes sense to allow local control over argument labels. For people who don’t care to have their closures be applied with labels, maybe allow current syntax:</div><div><br class=""></div><div><div>let projectedFunction = projected(function: fToApply)</div><div>let scale = projectedFunction(myPoint1, myPoint2)</div><div>let finalPoint = scale(3.0)</div><div class=""><br class=""></div><div class="">I’m not sure if we want to force compound names always (demonstrate arity and explicit label-less-ness), but one could envision a strict enforcement like:</div><div class=""><br class=""></div><div class=""><div>let projectedFunction(_:_:) = projected(function: fToApply)</div><div>let scale(_:) = projectedFunction(myPoint1, myPoint2)</div><div>let finalPoint = scale(3.0)</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Probably out of scope for Swift 4 stage 1</div></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">-- E</div><div class=""><br class=""></div></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>