[swift-dev] Swift's handling of function types

Joe Groff jgroff at apple.com
Mon Aug 29 11:02:07 CDT 2016


> On Aug 27, 2016, at 9:28 AM, Jens Persson via swift-dev <swift-dev at swift.org> wrote:
> 
> IMHO Swift's handling of function types violate the principle of least surprise.
> 
> In the example program below, are `a` and `b` really of the same function type?
> 
> I searched but couldn't find any proposal or discussion addressing this.
> 
> 
> // (Xcode 8 beta 6, toolchain: development snapshot 2016-08-26)
> 
> let a:  (Int, Int)  -> Int = { (a, b) in a + b }
> let b: ((Int, Int)) -> Int = a
> // So `a` can be casted to `b`'s type, OK.

This is no longer intended to be the case in Swift 3. The former has two arguments, the latter has one argument. The implementation has not fully caught up with this change, though.

-Joe


More information about the swift-dev mailing list