<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><blockquote type="cite">On May 3, 2016, at 11:51 PM, Xiaodi Wu via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:</blockquote></div><div><br></div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
* What is your evaluation of the proposal?<br></blockquote><div><br></div><div>+1. A very useful function to have on collections.</div><div><br></div><div>In FORTRAN and in languages that take inspiration from it, the same function is called a "circular shift"--IMO, it's a clearer name both by its associations with other uses of the term "shifting" and because googling the term will give much more useful results.</div><div><br></div><div>IMO, the parameter label could also use some bikeshedding. One reason is that, with an `Array<Int>` (as illustrated in the examples given), the argument in `array.rotate(firstFrom: 5)` does not obviously refer to an index. Superficially, this could mean first from the first element equal to 5.</div><div><br></div><div>One suggestion I would put forward is: `circularShift(leftBy: IndexDistance)`. For bidirectional and random access collections, this function could possibly be complemented by `circularShift(rightBy: IndexDistance)`.</div><div><br></div><div>Finally, I wonder whether the C++11-like behavior of returning the new index of the former first item is a very Swifty behavior. I could be persuaded if the return value is demonstrably something that is not always trivial to compute.</div></div></div></div></div></blockquote><div><br></div><div><span style="background-color: rgba(255, 255, 255, 0);">For random-access collections, calculating the new index is trivial, but for forward or bidirectional collections it's an O(n) operation if not calculated as part of the rotation. For the same reason, it's important that the parameter is an index and not just a distance.</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><span style="background-color: rgba(255, 255, 255, 0);">Nate</span><div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
* Is the problem being addressed significant enough to warrant a change to Swift?<br></blockquote><div><br></div><div>It's an additive feature, and it's hard to see any drawbacks.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
* Does this proposal fit well with the feel and direction of Swift?<br></blockquote><div><br></div><div>Yes, it's an algorithm of appropriate complexity and general utility to be added to the stdlib.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
* If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?<br></blockquote><div><br></div><div>This proposal presents the same algorithm as found in other languages but borrows the name from C++. Other names may be more self-documenting (see above).</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
* How much effort did you put into your review? A glance, a quick reading, or an in-depth study?<br></blockquote><div><br></div><div>I have read the proposal to a medium depth.</div></div></div></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></div></body></html>