[swift-evolution] Thoughts on making NSOperatingSystemVersion Comparable?

Robert S Mozayeni dev at mzy.me
Tue Jan 26 17:04:54 CST 2016


> Discussion is fine, of course, but you should bring this up with Tony or Philippe on the swift-corelibs-dev list.

I discussed this briefly with Philippe through GitHub, and he suggested I file a proposal: https://github.com/apple/swift-corelibs-foundation/pull/240

I’m still interested in getting feedback from the community before I actually draft a formal proposal.

-Robert


> On Jan 26, 2016, at 5:59 PM, Jordan Rose <jordan_rose at apple.com> wrote:
> 
> Since the corelibs version of Foundation is meant to match the Darwin version (for the most part), this is more a question for the owners of the Darwin Foundation framework (and overlay). Fortunately, they're the same people maintaining the corelibs port (Tony Parker, Philippe Hausler, and others), and they have the freedom to make such decisions without going through the full Swift evolution process.
> 
> Discussion is fine, of course, but you should bring this up with Tony or Philippe on the swift-corelibs-dev list.
> 
> Jordan
> 
> 
>> On Jan 26, 2016, at 3:32, Robert S Mozayeni via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> 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 <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 <https://github.com/apple/swift-package-manager/blob/39fdccc74fcb11bc0a352b73fb7e656ba6843ff4/Sources/PackageDescription/Version.swift#L23>
>> 
>> 
>> Tests: https://github.com/rsmoz/swift-corelibs-foundation/commit/db44f29e42f29ad0fe35f69ac83d853453c77bc6 <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
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160126/65816de8/attachment.html>


More information about the swift-evolution mailing list