[swift-evolution] [Proposal] Conventionalizing stride semantics

Thorsten Seitz tseitz42 at icloud.com
Sat Mar 5 04:56:32 CST 2016

> Am 03.03.2016 um 23:25 schrieb Dave Abrahams via swift-evolution <swift-evolution at swift.org>:
>> on Thu Mar 03 2016, Erica Sadun <erica-AT-ericasadun.com> wrote:
>> Should ranges drop that precondition then? So they can represent
>> forward and backward progressions?

I think that makes a lot of sense, except for one thing: how would we express an empty range??

> I'm very reluctant, though I'll admit my reasoning is based more on gut
> design instict than anything rational.  
> If you look at the work Dmitri is doing, the requirements on indices are
> being weakened to Equatable but then strengthened to Comparable, in part
> so we can do range validation and catch errors early.  It feels very
> weird to me to say that you can form a Range of any two equatable
> things.  At that point, one almost might as well replace Range with
> (T,T) where T:Equatable.

The difference would be that a Range can contain behavior like stride() which makes it more than just a tuple.


More information about the swift-evolution mailing list