[swift-corelibs-dev] Proposal: Conforming NSDate to Comparable
Chris Amanse
christopheramanse at gmail.com
Sat Dec 5 18:48:30 CST 2015
Here's a draft of the the proposal:
https://gist.github.com/chrisamanse/2ab39e31e93d5c11d0b5
On Sun, Dec 6, 2015 at 7:52 AM Philippe Hausler <phausler at apple.com> wrote:
> In all that seems like a pretty reasonable concept. Foundation is going to
> be using the same evolution template as the rest of the Swift evolution
> process; could you fill out a draft of that and I can help campion your
> proposal to the component owner for NSDate and we can see how this will
> fair with the rest of the Darwin side of things.
>
> As you can probably guess; operators are not taken lightly since they
> exist in the global scope and it is good to consider the ramifications of
> what even something as simple as comparison of dates has in general.
>
> On Dec 5, 2015, at 3:36 PM, Chris Amanse via swift-corelibs-dev <
> swift-corelibs-dev at swift.org> wrote:
>
> Hello Swift Developers,
>
> I think it's a good idea to conform NSDate to the Comparable protocol, so
> instead of using:
>
> if someDate.compare(today) == .OrderedAscending { }
>
> Developers can easily compare using compare dates using comparison
> operators:
>
> if someDate < today { }
>
> In my opinion, the code is still readable if developers use comparison
> operators on NSDates.
>
> Here's a quick implementation from my swift-corelibs-foundation fork:
> https://github.com/chrisamanse/swift-corelibs-foundation/commit/3c4eff643c5271de5bec2461798051347be13916
>
> Thank you.
>
> _______________________________________________
> swift-corelibs-dev mailing list
> swift-corelibs-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-corelibs-dev
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-corelibs-dev/attachments/20151206/c1d48c56/attachment.html>
More information about the swift-corelibs-dev
mailing list