<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></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 May 6, 2016, at 3:18 PM, Dave Abrahams via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><div class=""><br 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;" class=""><span 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; float: none; display: inline !important;" class="">on Thu May 05 2016, Nate Cook <</span><a href="mailto:swift-evolution@swift.org" 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;" class="">swift-evolution@swift.org</a><span 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; float: none; display: inline !important;" class="">> wrote:</span><br 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;" class=""><br 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;" class=""><blockquote type="cite" 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;" class="">Thanks for the feedback, Dmitri &co, this all looks excellent! I'll work on updating the proposal.<br class=""><br class=""><blockquote type="cite" class="">On May 5, 2016, at 6:13 PM, Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com" class="">gribozavr@gmail.com</a>> wrote:<br class=""><br class="">On Tue, May 3, 2016 at 8:57 PM, Chris Lattner via swift-evolution<br class=""><<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><blockquote type="cite" class="">Hello Swift community,<br class=""><br class="">The review of "SE-0078: Implement a rotate algorithm, equivalent to std::rotate() in C++" begins now and runs through May 9.<br class=""></blockquote><br class="">Hi,<br class=""><br class="">I'm posting this feedback on behalf of Dave Abrahams, Max Moiseev and<br class="">myself. We met and discussed the proposal in great detail.<br class=""><br class="">First of all, we want to thank Nate and Sergey for proposing this API,<br class="">which is an important and useful algorithm. We are generally in favor<br class="">of the proposal, but we would like to request a few changes.<br class=""><br class="">Could you make 'func rotate' a requirement in the MutableCollection<br class="">protocol? This allows selecting the best implementation for a given<br class="">concrete type, even when calling from generic code.<br class=""><br class="">Could you explain why do we need a special implementation of<br class="">'reverse()' for RandomAccessCollection? We couldn't think of a<br class="">performance reason for this.<br class=""></blockquote><br class="">With a bidirectional collection, you have to compare the high and low<br class="">index at each iteration, stopping when low >= high (before indices<br class="">were Comparable, this required two equality comparisons per<br class="">iteration). With a random-access collection, you can optimize the loop<br class="">to use a fixed number of iterations, which should be more efficient.<br class=""></blockquote><br 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;" class=""><span 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; float: none; display: inline !important;" class="">How can you reverse a variable-length collection with a fixed number of</span><br 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;" class=""><span 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; float: none; display: inline !important;" class="">iterations? Are you talking about loop unrolling in the library?</span><br 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;" class=""></div></blockquote><div><br class=""></div><div>I mean looping <font face="Menlo" class="">count / 2</font> times instead of looping while <font face="Menlo" class="">lowIndex < highIndex</font>, not a fixed number of iterations for every array.</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><blockquote type="cite" 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;" class=""><blockquote type="cite" class="">Could you add complexity clauses to all new documentation comments?<br class=""><br class="">We have discussed the names for these functions at length. We felt<br class="">like the argument in 'rotate(firstFrom:)' does not convey the<br class="">argument's role well. Our suggestion is to use<br class="">'rotate(shiftingToStart:)' and 'rotated(shiftingToStart:)'. These<br class="">names emphasize that methods operate on the whole collection, shifting<br class="">all elements. The argument is the index of the element that is moved<br class="">to the start index, and we tried to convey that by using the word<br class="">'start' instead of 'first'. In the standard library, 'first' refers<br class="">to the element itself, not the index. Indices use 'startIndex' and<br class="">'endIndex'.<br class=""><br class="">We have considered a lot of alternative names, including<br class="">'swapSubranges(boundedBy:)', 'rewind', 'splitAndSwap', 'swapHalves'<br class="">and others, but they were not as good. The problems are:<br class=""><br class="">- 'swapSubranges' is mostly good, but 'subranges' does not imply that<br class="">the two subranges cover the whole collection. The user might<br class="">reasonably expect to pass two subranges that will be swapped.<br class=""><br class="">- 'Half' implies that two parts make a whole, but it also implies that<br class="">two parts are of equal size, which is not the case for this API.<br class=""><br class="">- 'splitAndSwap' implies that we are operating on the whole, but feels<br class="">a very roundabout way to describe the operation.<br class=""></blockquote><br class="">Agreed on all of this. The rotate name is hard to beat!<br class=""><br class=""><blockquote type="cite" class="">For a non-mutating rotation we suggest defining separate types,<br class="">RotatedCollection, RotatedBidirectionalCollection, and<br class="">RotatedRandomAccessCollection, instead of returning a<br class="">FlattenCollection. This has a few advantages.<br class=""><br class="">- We can change the non-mutating 'rotated()' to just return the<br class="">collection instead of returning tuples of the collection and the<br class="">index. The index of the former first element can be stored inside the<br class="">RotatedCollection in a property. This change allows easier chaining<br class="">on '.rotated()', and goes in line with the return value of the<br class="">mutating 'rotate()' being discardable.<br class=""><br class="">- Using an array in the return type of 'rotated()'<br class="">(FlattenCollection<[Self.SubSequence]>) would be less efficient than<br class="">it could be (extra allocation), and also feels like exposing too many<br class="">implementation details that we might want to change in future (for<br class="">example, if we get a CollectionOfTwo type).<br class=""><br class="">- In future, when we have conditional protocol conformances in the<br class="">language, we would fold the three RotatedCollection types into one<br class="">type that conditionally conforms to collection protocols based on the<br class="">capabilities of the underlying collection. We won't be able to do<br class="">that if some overloads return a FlattenCollection.<br class=""><br class="">For lazy 'rotated()', just like for non-mutating 'rotated()', we<br class="">recommend returning only one value, a LazyCollection that wraps an<br class="">appropriate RotatedCollection. The RotatedCollection will store the<br class="">index of the former first element in a property.<br class=""><br class="">Dmitri<br class=""><br class="">--<span class="Apple-converted-space"> </span><br class="">main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if<br class="">(j){printf("%d\n",i);}}} /*Dmitri Gribenko <<a href="mailto:gribozavr@gmail.com" class="">gribozavr@gmail.com</a>>*/<br class=""></blockquote><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></blockquote><br 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;" class=""><span 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; float: none; display: inline !important;" class="">--<span class="Apple-converted-space"> </span></span><br 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;" class=""><span 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; float: none; display: inline !important;" class="">Dave</span><br 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;" class=""><br 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;" class=""><span 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; float: none; display: inline !important;" class="">_______________________________________________</span><br 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;" class=""><span 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; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br 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;" class=""><a href="mailto:swift-evolution@swift.org" 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;" class="">swift-evolution@swift.org</a><br 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;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" 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;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></body></html>