[swift-evolution] [Review] SE-0065 A New Model for Collections and Indices
Shawn Erickson
shawnce at gmail.com
Mon Apr 11 15:31:39 CDT 2016
On Mon, Apr 11, 2016 at 1:01 PM Dave Abrahams via swift-evolution <
swift-evolution at swift.org> wrote:
>
> > Compared to this:
> >
> > collection.index(5, stepsFrom: i)
> >
> > I would prefer any of these (ordered from least favorite to most):
> >
> > collection.index(distance: 5, from: i)
>
> I'm OK with this one, but am not sure it's an improvement over the
> proposal. I'd like to hear other peoples' arguments on this.
>
Just to throwing out some additional ideas...
"index moved x steps from i"
index = collection.index(moved: 5, stepsFrom: i)
index = collection.index(moved: -10, stepsFrom: i)
"index offset x from i"
index = collection.index(offset: 5, from: i)
index = collection.index(offset: -10, from: i)
"index advanced x from i"
index = collection.index(advanced: 5, from: i)
index = collection.index(advanced: -10, from: i)
...of course also start to wonder why not the following...
"index after/before i"
index = collection.index(after:i)
index = collection.index(before:i)
...instead of the separately name styled successor / predecessor functions.
I am still hesitant about the use of "form" for in the in place variants,
throwing out more ideas, of course these break from the "index" style
naming above but on could argue the above naming is attempting to imply you
get a new index back while the following are attempting to avoid that.
"move index i by x"
collection.move(index: i, by: 5)
collection.offest(index: i, by: -3)
"offset index i by x"
collection.offest(index: i, by: 5)
collection.offest(index: i, by: -3)
"advance index i by x"
collection.advance(index: i, by: 5)
collection.advance(index: i, by: -3)
I think I like the ones using advance the best and if the "index(" ones are
the path forward I would lobby for index(after:)/index(before:) instead of
successor and predecessor.
-Shawn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160411/5134c1e6/attachment.html>
More information about the swift-evolution
mailing list