I hope they do adopt that suggested change to method calls. Swift is a nice language, but there's still some awkwardness due to its required compatibility with Objective C. I think if you don't come from that background, then having all named arguments <i>except</i> the first one seems really arbitrary and nonsensical.
The title they chose implies that they're actually changing the APIs to take full advantage of Swift language features. Perhaps they should have named the article "We're renaming some classes and methods."
Could they just go all the way and use a mandatory first argument name to make things even more concise? That would get away from something that annoys a lot of people about Swift, the implicitly unnamed first arguments.<p>Something like this:<p><pre><code> class BezierPath: NSObject {
func add(LineTo lineTo: CGPoint) {}
func add(ArcWithCenter center: CGPoint, radius: CGFloat,
startAngle: CGFloat, endAngle: CGFloat,
clockwise: Bool) {}
func add(CurveTo endPoint: CGPoint, controlPoint1 point1: CGPoint,
controlPoint2 point2: CGPoint) {}
func add(QuadCurveTo endPoint: CGPoint, controlPoint: CGPoint) {}
}
class main {
func run() {
let path = BezierPath()
let point1 = CGPoint()
let point2 = CGPoint()
path.add(LineTo: CGPoint(x: 100, y: 0))
path.add(ArcWithCenter: CGPointZero, radius: 20.0,
startAngle: 0.0, endAngle: CGFloat(M_PI) * 2.0,
clockwise: true)
path.add(CurveTo: CGPoint(x: 100, y: 0), controlPoint1: point1,
controlPoint2: point2)
path.add(QuadCurveTo: point2, controlPoint: point1)
}
}
</code></pre>
The difference is mostly that it looks even more concise when using code completion. You would see:<p><pre><code> path.add(LineTo: CGPoint)
</code></pre>
Instead of:<p><pre><code> path.addLineTo(point: CGPoint)</code></pre>
I do wish the Swift developers had allowed actual Objective-C calls in Swift to make it look the same.<p>Objective-C<p><pre><code> [aPath addLineToPoint:CGPointMake(200.0, 40.0)];
</code></pre>
proposed<p><pre><code> aPath.(addLineToPoint:CGPoint(200.0, 40.0));
</code></pre>
the more complicated example would be:<p>Objective-C<p><pre><code> [object selector1:item1 selector2:item2];
</code></pre>
to<p><pre><code> object.(selector1:item1, selector2:item2);
</code></pre>
although I'm still not sure about the love of commas