[swift-evolution] Feature proposal: Range operator with step

Brent Royal-Gordon brent at architechies.com
Mon Mar 28 19:33:20 CDT 2016

>> Floating-point seconds (as NSTimeIntervals) are the natural Strideable.Stride, but it's not particularly clear to me that you want 1 second to be a default stride. It's the default you would guess, but it's not actually a particularly useful default.
> Any fixed-time-period stride with dates is fraught with peril. Not every day is 24 hours, not every minute is 60 seconds, etc. Working with dates requires enough special domain knowledge that I think it'd be harmful to try to genericize numeric concepts over it.

While this is true, "ten seconds from now" is always ten seconds from now, and "seconds between date1 and date2" is always the same number of seconds. There is a basic level of time measurement and manipulation which is completely independent of time zones and calendars; that's what NSDate and NSTimeInterval represent. They are needed fairly often, and they are perfectly compatible with Strideable's semantics.

Brent Royal-Gordon

More information about the swift-evolution mailing list