<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Apr 11, 2016 at 1:01 PM Dave Abrahams via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
> Compared to this:<br>
><br>
> collection.index(5, stepsFrom: i)<br>
><br>
> I would prefer any of these (ordered from least favorite to most):<br>
><br>
> collection.index(distance: 5, from: i)<br>
<br>
I'm OK with this one, but am not sure it's an improvement over the<br>
proposal. I'd like to hear other peoples' arguments on this.<br></blockquote><div><br></div></div><div dir="ltr"><div class="gmail_quote"><div>Just to throwing out some additional ideas...</div><div><br></div><div>"index moved x steps from i"</div><div>index = collection.index(moved: 5, stepsFrom: i)</div><div><span style="color:rgb(0,0,0)"><span style="color:rgb(0,0,0)"><span style="color:rgb(0,0,0)">index </span>= </span>collection.index(moved: -10, stepsFrom: i)</span></div><div><span style="color:rgb(0,0,0)"><br></span></div><div><span style="color:rgb(0,0,0)">"index offset x from i"</span></div><div><div style="color:rgb(0,0,0)"><span style="color:rgb(0,0,0)"><span style="color:rgb(0,0,0)">index </span>= </span>collection.index(offset: 5, from: i)</div><div style="color:rgb(0,0,0)"><span style="color:rgb(0,0,0)"><span style="color:rgb(0,0,0)">index </span>= </span>collection.index(offset: -10, from: i)</div><div style="color:rgb(0,0,0)"><br></div><div style="color:rgb(0,0,0)">"index advanced x from i"</div><div style="color:rgb(0,0,0)"><span><div style="color:rgb(0,0,0)"><span style="color:rgb(0,0,0)"><span style="color:rgb(0,0,0)">index </span>= </span>collection.index(advanced: 5, from: i)</div><div style="color:rgb(0,0,0)"><span style="color:rgb(0,0,0)"><span style="color:rgb(0,0,0)">index</span> = </span>collection.index(<span style="color:rgb(0,0,0)">advanced</span>: -10, from: i)</div><div style="color:rgb(0,0,0)"><br></div><div style="color:rgb(0,0,0)">...of course also start to wonder why not the following...</div><div style="color:rgb(0,0,0)"><br></div><div style="color:rgb(0,0,0)">"index after/before i"</div><div style="color:rgb(0,0,0)"><span><span style="color:rgb(0,0,0)">index </span><span style="color:rgb(0,0,0)">= </span></span>collection.index(after:i)</div><div style="color:rgb(0,0,0)"><span><span style="color:rgb(0,0,0)">index </span><span style="color:rgb(0,0,0)">= </span></span>collection.index(before:i)</div><div style="color:rgb(0,0,0)"><br></div><div style="color:rgb(0,0,0)">...instead of the separately name styled successor / predecessor functions.</div><div style="color:rgb(0,0,0)"><br></div><div style="color:rgb(0,0,0)">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.</div><div style="color:rgb(0,0,0)"><br></div><div style="color:rgb(0,0,0)"><span style="color:rgb(0,0,0)">"move index i by x"</span><br></div><div style="color:rgb(0,0,0)">collection.move(<span style="color:rgb(0,0,0)">index: i</span>, by: 5)</div><div style="color:rgb(0,0,0)"><span><span style="color:rgb(0,0,0)">collection.offest(</span><span style="color:rgb(0,0,0)">index: i</span><span style="color:rgb(0,0,0)">, by: -3)</span></span><br></div><div style="color:rgb(0,0,0)"><span><span style="color:rgb(0,0,0)"><br></span></span></div><div style="color:rgb(0,0,0)"><span style="color:rgb(0,0,0)">"offset index i by x"</span><br></div><div style="color:rgb(0,0,0)">collection.offest(<span style="color:rgb(0,0,0)">index: i</span>, by: 5)</div><div style="color:rgb(0,0,0)"><span><span style="color:rgb(0,0,0)">collection.offest(</span><span style="color:rgb(0,0,0)">index: i</span><span style="color:rgb(0,0,0)">, by: -3)</span></span><br></div><div style="color:rgb(0,0,0)"><span><span style="color:rgb(0,0,0)"><br></span></span></div><div style="color:rgb(0,0,0)"><span style="color:rgb(0,0,0)">"advance index i by x"</span><br></div><div style="color:rgb(0,0,0)">collection.advance(index: i, by: 5)</div></span><span style="color:rgb(0,0,0)">collection.advance(index: i, by: -3)</span><br></div><div style="color:rgb(0,0,0)"><span style="color:rgb(0,0,0)"><br></span></div><div>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.</div><div style="color:rgb(0,0,0)"><br></div>-Shawn</div><div> <br></div></div></div></div>