<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Dec 28, 2015 at 10:29 PM, Sergey Bolshedvorsky 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"><div style="word-wrap:break-word">Hi all,<div><br></div><div>I have created a PR with with a formal proposal for this feature: <a href="https://github.com/apple/swift-evolution/pull/77" target="_blank">https://github.com/apple/swift-evolution/pull/77</a></div><div><br></div><div>What are your thoughts?</div></div></blockquote><div><br></div><div>Thank you for the proposal!</div><div><br></div><div>What jumps at me immediately is that the APIs are using integers to specify positions in the collection. I think they should be using collection's indices instead.</div><div><br></div><div>I'm unsure why we need `first` and `last` -- shouldn't the API operate on the whole collection? We have slices to operate on subsequences.</div><div><br></div><div>It is interesting that you are proposing that the new algorithms should produce lazy views. I agree this is consistent with the rest of the library, but I'm worried about the performance implications. Have you thought about this? One point to keep in mind is that you can implement the `_copyToNativeArrayBuffer()` and `_initializeTo()` entry points in all new lazy collections, using the optimal eager algorithm. This way, converting them to arrays will be fast.</div></div><div class="gmail_extra"><br></div>Another point to consider is how the call site of these functions looks like:</div><div class="gmail_extra"><br></div><div class="gmail_extra">collection.rotate(10, middle: 20, last: 30)</div><div class="gmail_extra"><br></div><div class="gmail_extra">The first number hangs in the air, it is unclear what its meaning is.</div><div class="gmail_extra"><div><br></div><div>Dmitri</div><div><br></div>-- <br><div class="gmail_signature">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" target="_blank">gribozavr@gmail.com</a>>*/</div>
</div></div>