<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 Mar 8, 2016, at 11:49 AM, Dave Abrahams via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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 Tue Mar 08 2016, plx &lt;</span><a href="mailto:swift-evolution@swift.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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: 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="">&gt; wrote:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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: 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: 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="">On Mar 3, 2016, at 3:28 PM, Dmitri Gribenko &lt;<a href="mailto:gribozavr@gmail.com" class="">gribozavr@gmail.com</a>&gt;<br class="">wrote:<br class=""></blockquote><br class="">I think it’s possible to adjust the protocol hierarchy to “reserve<br class="">room”—remove `Indexable`’s methods from `Collection`, add them back to<br class="">a new `ForwardCollection` between `Collection` and<br class="">`BidirectionalCollection`—but it’d only make sense to do that if you<br class="">expect to have use for that room in the future.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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: 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="">This is something we expressly don't do in generic programming.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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: 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="">Protocols (concepts) are spawned only by the existence of real-world</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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: 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="">use-cases, and enough of them to make the generality worthwhile.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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>Apologies for the long delay in replying. I’ll keep this somewhat brief b/c:</div><div><br class=""></div><div>- it’s been almost a month</div><div>- it’s perfectly-feasible for me to tack-on my own little hierarchy for my own needs, if necessary</div><div><br class=""></div><div>…so even though I would personally *prefer* that `Collection` be defined as *having-a* canonical linearization (as opposed to *being-a* linearization), it doesn't seem to be of pressing concern.</div><div><br class=""></div><div>I do, however, have an alternative proposal: would it be possible to have `Collection` support some methods like these (but with less-atrocious naming):</div><div><br class=""></div><div>&nbsp; // MARK: Basic “Unordered” Iteration</div><div><div><br class=""></div><div><div>&nbsp; /// Like `forEach`, but need not *necessarily* visit elements in the same order as you would</div><div>&nbsp; /// see them in a for-in loop; meant for use for when all you need is to visit each element in *some* order.</div><div>&nbsp; func unorderedForEach(@noescape visitor: (Self.Generator.Element) throws -&gt; Void) rethrows</div><div><br class=""></div><div><div><div>&nbsp; /// Type of the sequence for `unorderedElements`; a default that is `== Self` seems reasonable.</div><div>&nbsp; associatedtype UnorderedElementSequence: Sequence where UnorderedElementSequence.Generator.Element == Self.Generator.Element</div><div class=""><br class=""></div><div class=""><div>&nbsp; /// Returns a sequence that visits all elements in `self` in *some* order, but not</div><div>&nbsp; /// necessarily the same order as a for-in loop (and not *necessarily* the same</div><div>&nbsp; /// ordering as-in `unorderedForEach`…)</div><div>&nbsp; func unorderedElements() -&gt; UnorderedElementSequence</div><div><br class=""></div><div>…and perhaps also some methods like these:</div><div></div></div></div><div><br class=""></div><div>&nbsp; // MARK: “Unordered” Enumeration (Index + Element)</div><div class=""><br class=""></div><div class=""><div>&nbsp; /// Like `unorderedForEach`, but the closure is given `(indexOfElement, element)` rather than</div><div>&nbsp; /// just `element` itself; the name here is terrible in particular. No guarantee the ordering is</div><div>&nbsp; /// the same as the ordering for unorderedForEach</div><div>&nbsp; func&nbsp;unorderedEnumeratedForEach(@noescape visitor: (Self.Index,Self.Generator.Element) throws -&gt; Void) rethrows</div></div><div class=""><br class=""></div></div><div>&nbsp; /// Type of the sequence for `unorderedEnumeration&nbsp;`; a default that is identical to what `self.enumerate()` returns seems reasonable.</div><div>&nbsp; associatedtype UnorderedEnumerationSequence: Sequence where UnorderedElementSequence.Generator.Element == (Self.Index,Self.Generator.Element)</div><div><br class=""></div><div><div>&nbsp; /// Returns a sequence that visits all pairs of `(indexOfElement, element) in `self` in *some* order, but not</div><div>&nbsp; /// necessarily the same order as a for-in loop.</div><div>&nbsp; func unorderedEnumeration() -&gt; UnorderedEnumerationSequence</div><div class=""><br class=""></div><div class="">…?</div><div class=""><br class=""></div><div class=""><div class="">If you want a motivating example, suppose you have a k-ary tree-like implemented as a packed array (in the usual way).</div><div class=""><br class=""></div><div class="">Obviously the “standard” for-in/index/etc. iteration should respect the “tree ordering”; but, if all you’re doing is this:</div><div class=""><br class=""></div><div class="">&nbsp; // or `for view in contentViews`...</div><div class="">&nbsp; contentViews.forEach() { $0.hidden = false }</div><div class=""><br class=""></div><div class="">…it’d be nice to be able to write something like this:</div><div class=""><br class=""></div><div class="">&nbsp; // or `for view in contentViews.unorderedElements()`...</div><div class="">&nbsp; contentViews.unorderedForEach() { $0.hidden = false }&nbsp;</div><div class=""><br class=""></div><div class="">…to avoid paying the cost of visiting things in order?</div><div class=""><br class=""></div><div class="">For concrete types you can always define such methods and call them when appropriate, but I think it’d be very handy to have such methods available in generic contexts.</div></div></div></div></div></div></body></html>