[swift-users] any wisdom about sharing "common" overloads/extensions in base libraries?
David Baraff
davidbaraff at gmail.com
Tue Jun 20 09:02:20 CDT 2017
I posted this on Apple’s developer forums, and someone suggested trying this here.
Basically, see https://forums.developer.apple.com/thread/80349 <https://forums.developer.apple.com/thread/80349>
but in a nutshell: consider that a widely used class/struct (such as CGPoint) is missing some “obvious” functionality [don’t debate that part, just go with it for now], such as the ability to scale a point by a scalar using * as an operator: so in my awesome library “GeometryBase” I write
public func * (left: CGPoint, right: double) -> CGPoint {
return CGPoint(x: right*left.x, y: right*left.y)
}
Why public? Well, of course, because I want to use library GeometryBase in many apps or other libraries, and now this overload exists in only one place.
But other bright people have the same idea, and now I want to use their libraries. (some of them in my company, some of them not.)
And now we’re stuck, because everyone is trying to make up for the same (perceived) lack and everyone wants them public so that they don’t have to keep sticking them in each library they write.
This is not a made up situation: many people even within one company trying to share code somewhat informally are going to write the same code to make using CGPoint/Size/Rect easier, and now we can’t share anything safely.
Anybody got some good ideas what to do about this?
[Same question could apply to adding extensions.]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170620/95bd64c9/attachment.html>
More information about the swift-users
mailing list