<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 7 Jul 2016, at 19:10, Karl &lt;<a href="mailto:raziel.im+swift-evo@gmail.com" class="">raziel.im+swift-evo@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 7 Jul 2016, at 17:19, Tim Vermeulen &lt;<a href="mailto:tvermeulen@me.com" class="">tvermeulen@me.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><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-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline">On 7 Jul 2016, at 16:57, Karl &lt;<a href="mailto:razielim@gmail.com" class="">razielim@gmail.com</a>&gt; wrote:<br class=""><br class=""><br class=""><blockquote type="cite" class="">On 7 Jul 2016, at 07:50, Tim Vermeulen via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class="">This is a follow up from this swift-users thread: <a href="https://lists.swift.org/pipermail/swift-users/Week-of-Mon-20160704/002489.html" class="">https://lists.swift.org/pipermail/swift-users/Week-of-Mon-20160704/002489.html</a><br class=""><br class="">As it stands, RangeReplaceableCollection requires an implementation for init(), which is used in the default implementations of (as far as I can tell) init(_:), init(repeating:count:) and removeAll(keepingCapacity:). The latter of these methods should be implementable with removeSubrange(_:) instead.<br class=""><br class="">I would like to propose to *remove* all three initialisers from this protocol, because it makes it impossible for some collections to conform to it that need extra data for its initialisation, but are otherwise perfectly capable of having arbitrary subranges replaced by elements from another collection. Those three initialisers could either move to a new protocol or simply not be part of any protocol.<br class=""><br class="">On a similar note, I’d like to have all initialisers of SetAlgebra removed as well, but that might need its own review.<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=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></blockquote><br class="">I believe the idea of RRC is that all you need to implement is the empty initialiser and replaceSubrange(), and everything else (e.g. Append, insert) is implemented in terms of those.<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="">Right, but as it turns out, the empty initialiser is used in barely any of them.</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-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">Even the initialiser which takes existing collection just initialises and empty one and appends the existing collection (I.e. Calling replaceSubrange).<br class=""><br class="">If I understand you correctly, it will not be possible to initialise a generic RRC any more, will it? Because that RRC may need additional information (e.g. A maximum buffer size if it stores its data in multiple discrete buffers) which you can’t provide generically.<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="">Correct. I haven’t come up with a use for initialising a generic RRC anyways, mostly because I think there are RRCs for which an empty init wouldn’t make any sense.</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-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><br class="">Maybe we could have a true copy-constructor instead? That is, replace init&lt;C:Collection&gt;(_:) with init(_: Self), so that it could take any additional arguments from that other instance?<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="">This is certainly an improvement over init(), but what would it be used for with regards to this particular protocol? It might certainly be useful, but the empty initialiser can be useful as well; it’s just a matter of how relevant that method is to this protocol. Wouldn’t a copy constructor make more sense in the more general Collection protocol?</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-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><br class="">Karl</blockquote></div></blockquote><br class=""></div><div class="">I have a use-case: I have a struct which wraps a RangeReplaceableCollection and allows you to tag ranges of indices with random objects (it’s actually pretty cool, it can automatically merge adjacent ranges of Equatables — sort of like a pure-Swift NSAttributedString). It needs to create a new collection (currently via the initialiser, but a copy-constructor would also be fine), because it needs to own the indexes for mutability guarantees.</div><br class=""><div class="">Karl</div></div></div></blockquote></div><br class=""><div class=""><br class=""></div><div class="">What I mean by that is that the wrapper needs to make sure that you never mutate the collection it references outside of its own replaceSubrange. Otherwise the parallel collection of tagged indexes would go out-of-sync.</div><div class=""><br class=""></div><div class="">Karl</div></body></html>