[swift-evolution] Thoughts on making NSOperatingSystemVersion Comparable?
Robert S Mozayeni
dev at mzy.me
Tue Jan 26 05:32:54 CST 2016
Hello.
I’ve recently forked swift-corelibs-foundation and implemented Comparable for NSOperatingSystemVersion.
What’s the point of this? Well, in the words of a friend, "It’s a value type with a clear ordering, why not?”.
I have also added a new initializer that allows something like
NSOperatingSystemVersion(10,11,4)
instead of requiring
NSOperatingSystemVersion(majorVersion: 10, minorVersion: 11, patchVersion: 4)
Not only is this new initializer easier to type, but it also much clearer, especially when one is quickly scanning through code.
My changes: https://github.com/rsmoz/swift-corelibs-foundation/commit/e3db7ae2d7f4ba27ae5597e157b41a4b34def468
Also, the Version struct in swift-package-manager has an extension for Comparable, as well as concise initializer:
https://github.com/apple/swift-package-manager/blob/39fdccc74fcb11bc0a352b73fb7e656ba6843ff4/Sources/PackageDescription/Version.swift#L23
Tests: https://github.com/rsmoz/swift-corelibs-foundation/commit/db44f29e42f29ad0fe35f69ac83d853453c77bc6
I’d like to hear your opinions on my changes. For instance, do you think implementing Comparable for NSOperatingSystemVersion would best be done in an extension? That’s how SwiftPM does it.
Best,
Robert Mozayeni
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160126/a4fb3efe/attachment.html>
More information about the swift-evolution
mailing list