Re: [swift-corelibs-dev] [swift-evolution] Proposal: Conforming NSDate to Comparable

2015-12-06 Thread Alexander Kolov via swift-corelibs-dev
I also agree, since all methods already exist in NSDate. Conforming it to 
Comparable and Strideable is just making interface more in line with Swift 
spirit.

> On Dec 6, 2015, at 11:05 AM, Brent Royal-Gordon via swift-corelibs-dev 
>  wrote:
> 
>> I agree that it makes perfect sense for NSDate to implement Strideable. I 
>> actually do that already in my extensions.
>> The concept of NSDate and NSTimeInterval fit with the concept, the chance of 
>> misusing it doesn't increase too much with more utilities as a developer 
>> either knows what it represent or it doesn't (if it doesn't search for it).
>> This shouldn't be used for date computations (and here I could say the name 
>> is ambiguous), but for time computations.
> 
> I obviously agree. But I’d also add that it might make sense to emit a 
> compiler warning for things that look like date math instead of time math—for 
> instance, constants divisible by 86400 (24 hours), or maybe even 3600 (60 
> minutes).
> 
> Actually, this might be a good idea even when no time APIs are obviously 
> involved. What are the chances your literal 86400 doesn’t have something to 
> do with a date?
> 
> -- 
> Brent Royal-Gordon
> Architechies
> 
> ___
> swift-corelibs-dev mailing list
> swift-corelibs-dev@swift.org
> https://lists.swift.org/mailman/listinfo/swift-corelibs-dev

___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


Re: [swift-corelibs-dev] Proposal: Conforming NSDate to Comparable

2015-12-06 Thread Tony Parker via swift-corelibs-dev
Hi Chris,

Thanks for bringing this idea to the list.

Is NSDate really the only thing that we want to conform to comparable, or is 
there a set of classes which should do so? I’d like to think about the larger 
set of consequences here (and if possible, deal with one coherent answer for 
all of Foundation rather than do these classes one at a time).

- Tony

> On Dec 5, 2015, at 3:36 PM, Chris Amanse via swift-corelibs-dev 
>  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@swift.org
> https://lists.swift.org/mailman/listinfo/swift-corelibs-dev

___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev


Re: [swift-corelibs-dev] [swift-evolution] Proposal: Conforming NSDate to Comparable

2015-12-06 Thread Stephen Celis via swift-corelibs-dev
Seems to me that anything with `-compare:` could conform to Comparable. The 
list, however, is surprisingly short, and half bridge over to native Swift 
types that are already Comparable:

- [NSDate compare:]
- [NSIndexPath compare:]
- [NSNumber compare:]
- [NSString compare:]

Looks like NSIndexPath may be the only other contender.

Stephen

> On Dec 6, 2015, at 11:47 AM, Tony Parker via swift-evolution 
>  wrote:
> 
> Hi Chris,
> 
> Thanks for bringing this idea to the list.
> 
> Is NSDate really the only thing that we want to conform to comparable, or is 
> there a set of classes which should do so? I’d like to think about the larger 
> set of consequences here (and if possible, deal with one coherent answer for 
> all of Foundation rather than do these classes one at a time).
> 
> - Tony
> 
>> On Dec 5, 2015, at 3:36 PM, Chris Amanse via swift-corelibs-dev 
>> mailto:swift-corelibs-dev@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@swift.org 
>> https://lists.swift.org/mailman/listinfo/swift-corelibs-dev 
>> 
> 
>  ___
> swift-evolution mailing list
> swift-evolut...@swift.org 
> https://lists.swift.org/mailman/listinfo/swift-evolution 
> 
___
swift-corelibs-dev mailing list
swift-corelibs-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-corelibs-dev