[swift-evolution] SE-0111 and Curried argument labels: Unintended Consequences
Douglas Gregor
dgregor at apple.com
Wed Oct 5 15:37:58 CDT 2016
> On Oct 5, 2016, at 8:15 AM, Jon Akhtar via swift-evolution <swift-evolution at swift.org> wrote:
>
> I agree this seems like a pretty serious oversight. This is very un-swifty. Currying at one time was touted as a language feature, now it is more of an afterthought.
I see it as a feature that has mostly been removed in Swift 3: SE-0002 <https://github.com/apple/swift-evolution/blob/master/proposals/0002-remove-currying.md> eliminating the syntax that defined curried functions, and SE-0042 <https://github.com/apple/swift-evolution/blob/master/proposals/0042-flatten-method-types.md> eliminates the production of curried functions when referring to an instance member. I think that’s because, as a language feature, currying wasn’t really carrying it’s conceptual weight: it wasn’t being used *that* often in practice, but—unless you’re already familiar with currying from another language—it’s a fairly complicated notion to understand, and Swift didn’t ever have a complete implementation of currying.
- Doug
>
> -Jon
>
> From: <swift-evolution-bounces at swift.org <mailto:swift-evolution-bounces at swift.org>> on behalf of Erica Sadun via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>>
> Reply-To: Erica Sadun <erica at ericasadun.com <mailto:erica at ericasadun.com>>
> Date: Tuesday, October 4, 2016 at 09:21
> To: swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>>
> Subject: [swift-evolution] SE-0111 and Curried argument labels: Unintended Consequences
>
> 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.
>
> ```
> public func projected(
> function f: @escaping (CGFloat) -> CGFloat) ->
> (_ p0: CGPoint, _ p1: CGPoint) ->
> (_ percent: CGFloat) -> CGPoint
> {
> ```
>
> Calling the first level of currying still reads acceptably:
>
> ```
> let projectedFunction = projected(function: fToApply)
> ```
>
> 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:
>
> ```
> let fixedFunction = projectedFunction(p0, p1)
> let value = fixedFunction(0.2)
> ```
>
> There's no way to give either the line segment start and end points or the percent-of-progress arguments any labels. Further, Xcode/QuickHelp does not provide any support for documenting the roles of each curried return type.
>
> Could this be addressed specifically for currying or has the boat sailed forever on this topic?
>
> -- E
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161005/e368ff30/attachment.html>
More information about the swift-evolution
mailing list