> I personally liked the original free-function syntax—"stride(from: -50, to: 
> 50, by: 9)".  When we got protocol extensions, we decided we'd prefer methods 
> everywhere except in a few special cases, and this clearly falls outside 
> those criteria.

I don't know about that—in `stride(from: -50, to: 50, by: 9)`, I don't see any 
particular reason to privilege the `from` over the `to`. I mean, I suppose 
`from` always starts the seqeunce whereas `to` doesn't always appear in it, but 
they still feel like peers which equally define the operation as a whole. This 
has definitely always bothered me about Swift 2.

Incidentally, I just thought of another issue with using negative values with 
normal intervals to walk backwards: What does `(10..<20).by(-2)` mean? A naive 
implementation would probably give you this:

        [20, 18, 16, 14, 12, 10]

It *should* mean this, which would not be useful terribly often:

        [18, 16, 14, 12, 10]

Meanwhile, you really want to be able to get this, but the types and operators 
for an open-start interval don't currently exist:

        [20, 18, 16, 14, 12]

I wonder if intervals might need another look, and maybe a redesign to make 
them more general.

-- 
Brent Royal-Gordon
Architechies

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

Reply via email to