<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jul 20, 2016, at 2:57 PM, Jonathan Hull via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><pre class="" style="white-space: pre-wrap; background-color: rgb(255, 255, 255);">><i class=""> True, people might try to get the iterator a second time, but we can
</i>><i class=""> make the iteratorProvider method optional (and trying to get an
</i>><i class=""> iterator from an iterator which is spent would return nil)
</i>><i class=""> and then they are forced to deal with the case where it was
</i>><i class=""> single-pass.
</i>
Now you can't loop over the same array multiple times.</pre></blockquote><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">I must be missing something. Isn’t that the point?</div></div><div class=""><br class=""></div><div class="">I mean, your version is called “IterableOnce”. Why do you want to iterate on IterableOnce more than once? The point (at least in my mind) is to provide a common interface for things that we want to iterate over a single time. If you want to iterate multiple times, use collection’s interface where you are guaranteed multi-pass.</div><div class=""><br class=""></div><div class="">That said, you actually can loop multiple times for collections by getting a new iterator from the provider (which could point to the same array storage). The optional just forces you to check for the single-pass case.</div><div class=""><br class=""></div><div class="">I have a feeling like I am missing your true meaning here though...</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Jon</div></div></div></blockquote></div><br class=""><div class="">Right - an iterator instance is single pass, but a method that returns an iterator may be able to make multiple iterators which iterate over the same sequence of values.</div><div class=""><br class=""></div><div class="">I still think ideally you can operate on iterators as streams of data directly, rather than requiring a base protocol. I understand how this could cause lots of duplication to have two ‘sequence’ implementations, however.</div><div class=""><br class=""></div><div class="">-DW</div><div class=""><br class=""></div></body></html>