[swift-evolution] [Review] SE-0005 Better Translation of Objective-C APIs Into Swift

Matthew Johnson matthew at anandabits.com
Wed Jan 27 14:10:10 CST 2016


> On Jan 27, 2016, at 1:45 PM, Ben Rimmington <me at benrimmington.com> wrote:
> 
> Matthew,
> 
>> On 27 Jan 2016, at 19:26, Matthew Johnson <matthew at anandabits.com> wrote:
>> 
>> This is better IMO:
>> 
>> func appendArc(center center: Point, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat, clockwise: Bool)
>> 
>> However, I think this is an example of where explicit annotation is probably necessary to get the best result.  A heuristic can’t always do the right thing and I think this example is past the point of diminishing returns for heuristics.
> 
> The "append" methods of the AppKit.NSBezierPath patch are:
> 
>>   func append(path: NSBezierPath)
>> +  func append(rect rect: Rect)
>> +  func append(points points: PointArray, count: Int)
>>   func appendWithOvalIn(rect: Rect)
>> +  func appendWithArc(center center: Point, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat, clockwise: Bool)
>> +  func appendWithArc(center center: Point, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat)
>>   func appendWithArcFrom(point1: Point, to point2: Point, radius: CGFloat)
>> +  func append(glyph glyph: NSGlyph, in font: NSFont)
>> +  func append(glyphs glyphs: UnsafeMutablePointer<NSGlyph>, count: Int, in font: NSFont)
>> +  func append(packedGlyphs packedGlyphs: UnsafePointer<Int8>)
>> +  func append(roundedRect rect: Rect, xRadius: CGFloat, yRadius: CGFloat)
> 
> Would you need to annotate all the methods?

Not all of them, but it does appear to me like several of them would need annotation to get the best results, regardless of what you think the best results are.  Which ones require annotation depends on what results you want of course.

> 
> -- Ben



More information about the swift-evolution mailing list