Curried functions in Swift made useless by named parameters

Originator:pavol.vaskovic
Number:rdar://19424721 Date Originated:09-Jan-2015 11:19 AM
Status:Closed Resolved:Duplicate
Product:Developer Tools Product Version:Xcode Version 6.2 (6C101) Beta 3
Classification: Reproducible:
 
Summary:
Swift’s functions defined with curried notation require names for second and further parameters on call sites. This makes them quite pointless. Using _ in function definition causes warning “Extraneous '_' in parameter” and has no effect.

Steps to Reproduce:
Using example from Swift Programming Language book, section Curried functions:

func addTwoIntsCurried(a: Int)(b: Int) -> Int {
    return a + b
}

should be equivalent to:

func addTwoIntsCurried(a: Int) -> (Int -> Int) {
    func addTheOtherInt(b: Int) -> Int {return a+b}
    return addTheOtherInt
}


But second definition can be invoked as: addTwoIntsCurried(4)(5)
The first definition requires folloving invocation: addTwoIntsCurried(4)(b: 5)

Expected Results:


Actual Results:


Version:
Xcode Version 6.2 (6C101) Beta 3

Comments

Duplicate of 17237268

By pavol.vaskovic at Jan. 17, 2015, 9:36 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!