<div dir="ltr">This more limited approach makes sense in light of the documented reasoning. However, as a renaming proposal, I feel like I should raise some points about the proposed name.<div><br></div><div>First, a naive interpretation of IterableOnce may cause a user to think that a for...in loop over an IterableOnce is guaranteed to execute at least once. It is not that a sequence is "iterable once." It could be iterable exactly zero times. Rather, after however many iterations, the iterating cannot take place from the beginning again.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><div>Second, the dictionary definition of "once" lists an ambiguity, where (at least in one source) the first meaning is "one time only." (See: <<a href="https://www.google.com/#q=define:once">https://www.google.com/#q=define:once</a>>.) This could lead to misinterpretations of the relationship where Collection is IterableOnce.</div><div><br></div><div>I would propose that perhaps Iterable is sufficient to convey the meaning. There is no a priori user expectation, I think, that something iterable remains unchanged on traversal.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 12, 2016 at 5:55 PM, Dmitri Gribenko via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi,<br>
<br>
I'd like to continue the discussion of the issue raised by David Waite<br>
inhttp://<a href="http://thread.gmane.org/gmane.comp.lang.swift.evolution/21295/" rel="noreferrer" target="_blank">thread.gmane.org/gmane.comp.lang.swift.evolution/21295/</a>:<br>
<br>
> My main motivation for proposing this is the potential for developer confusion. As stated during one of the previous threads on the naming of map, flatMap, filter, etc. methods on Sequence, Sequence has a naming requirement not typical of the rest of the Swift standard library in that many methods on Sequence may or may not be destructive. As such, naming methods for any extensions on Sequence is challenging as the names need to not imply immutability.<br>
<br>
I'd like to focus on a particular point: methods on Sequence can<br>
consume elements, but the APIs are not markedmutating.<br>
<br>
Dave Abrahams, Max Moiseev, and I have discussed this issue and we<br>
agree this problem is severe and worth solving, we also think that the<br>
likely solutions would be source-breaking, so it is important that we<br>
discuss it now.<br>
<br>
We have discussed a few options.<br>
<br>
- Rejected option: remove Sequence, let IteratorProtocol model<br>
single-pass data streams<br>
<br>
- Rejected option: use a syntactic marker, like sequence.consumedIn.map {}<br>
<br>
- Rejected option: mutating APIs on Sequence, non-mutating APIs on Collection<br>
<br>
Proposed: rename Sequence to IterableOnce or TraversableOnce. We think<br>
that Sequence does not convey the single-pass restriction clearly. The<br>
term "sequence" has been used in math (as in "integer sequence"), and<br>
since the math domain does not have mutation, "sequence" can be<br>
understood to mean "multi-pass", since you can traverse a sequence of<br>
integers an arbitrary number of times.<br>
<br>
We think that only the last option is viable in the Swift language as<br>
it exists now, without creating an undue burden for API vendors and<br>
users.<br>
<br>
For more details about rejection options, please see the full writeup:<br>
<a href="https://gist.github.com/gribozavr/47f4717f3afc762549383e94da7f748b" rel="noreferrer" target="_blank">https://gist.github.com/gribozavr/47f4717f3afc762549383e94da7f748b</a><br>
<span class=""><font color="#888888"><br>
Dmitri<br>
<br>
--<br>
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if<br>
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com">gribozavr@gmail.com</a>>*/<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</font></span></blockquote></div><br></div></div>