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

Dave Abrahams dabrahams at apple.com
Tue Apr 5 17:19:15 CDT 2016

on Tue Apr 05 2016, Xiaodi Wu <swift-evolution at swift.org> wrote:

> On Mon, Apr 4, 2016 at 1:22 PM, Dave Abrahams <dabrahams at apple.com> wrote:
>> on Sat Apr 02 2016, Xiaodi Wu <xiaodi.wu-AT-gmail.com> wrote:
>>> [snip]
>>> Not included:
>>> 1. I know Ranges are in flux, so I've held off on extending Range with
>>> a striding(by:) method in this proof-of-concept.
>> They're not in flux, except for not having been reviewed yet; they are
>> settled in the swift-3-indexing-model branch.
> Did not know that. Will have to study what's there in more detail.

Actually, let me amend that.  The protocols involved need to be
de-underscored, the doc comments need to be written, and I am noticing a
few missing things around the edges.  But the basic shape of it is stable.

>>> 2. No attempt at the suggested stride(from:to:steps:) quite yet.
>> #1 and #2 are mutually exclusive; we prefer #1 as it removes questions
>> about the meaning of "to" or "through."
> I wasn't aware that was the thinking. Limiting strides to
> `striding(by:)` removes the ability to express `stride(from: 0, to:
> -10, by: -1)` because Range enforces (and it looks like it will
> continue to do so in the swift-3-indexing-model branch?) `lowerBound
> <= upperBound`, and in a half-open range it's the upper bound that's
> excluded.
>>> 2. No tests written yet for this proof-of-concept; I noticed that
>>> there's a stub for testing strides with bounds of type Double, but
>>> there's a comment about things not being ready because Double conforms
>>> to RandomIndexType--not sure what to make of that.
>> Comments in that branch are badly out-of-date.  It's worth trying that,
>> especially since there is no RandomAccessIndexType in that branch any
>> longer.
>>> 3. Haven't gotten around to testing performance.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution


More information about the swift-evolution mailing list