<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">I’m sorry, but I think we disagree on the premise. &nbsp;In my opinion the square brackets do exactly what we need them to do, and it’s not for the sake of anything other than consistency with the rest of the library and incidentally, reducing API complexity that I want to use them.<br><br><div id="AppleMailSignature">Sent from my iPad</div><div><br>On Sep 30, 2017, at 6:04 PM, Taylor Swift &lt;<a href="mailto:kelvin13ma@gmail.com">kelvin13ma@gmail.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">okay, well until someone can come up with a subscript syntax that does what we need it to do, I’m inclined to view <span style="font-family:monospace,monospace">at:from:</span> in the function parameter list as the clearest and most straightforward syntax. We shouldn’t use the square brackets for the sake of using square brackets.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 30, 2017 at 6:51 PM, Dave Abrahams <span dir="ltr">&lt;<a href="mailto:dabrahams@apple.com" target="_blank">dabrahams@apple.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space">I don't think I made any arguments that could be viewed as pointing out a problem with the slice approach, unless you take as given the idea that the slice approach should mean something novel and unprecedented. I don't see the whole/part implication that you see in the two notations, even though I understand why you want to read it that way, in particular <u>because</u>&nbsp;of the precedent I cited.<div><div><div><div class="h5"><div><br><blockquote type="cite"><div>On Sep 30, 2017, at 4:23 PM, Taylor Swift &lt;<a href="mailto:kelvin13ma@gmail.com" target="_blank">kelvin13ma@gmail.com</a>&gt; wrote:</div><br class="m_2788854386285137500Apple-interchange-newline"><div><div dir="ltr">yeah, which is why I think the <span style="font-family:monospace,monospace">at:from:</span> system is better than any subscript alternative. I know everyone wants to use the square brackets but it just doesn’t work very well for exactly the reasons you mentioned.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 30, 2017 at 6:07 PM, Dave Abrahams <span dir="ltr">&lt;<a href="mailto:dabrahams@apple.com" target="_blank">dabrahams@apple.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><div class="m_2788854386285137500h5"><br><div><br><blockquote type="cite"><div>On Sep 29, 2017, at 4:03 PM, Taylor Swift &lt;<a href="mailto:kelvin13ma@gmail.com" target="_blank">kelvin13ma@gmail.com</a>&gt; wrote:</div><br class="m_2788854386285137500m_-5832259184978187411Apple-interchange-newline"><div><div dir="auto"><div></div><div><br></div><div><br>On Sep 29, 2017, at 5:56 PM, Dave Abrahams &lt;<a href="mailto:dabrahams@apple.com" target="_blank">dabrahams@apple.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><br><div><br><blockquote type="cite"><div>On Sep 29, 2017, at 3:48 PM, Taylor Swift &lt;<a href="mailto:kelvin13ma@gmail.com" target="_blank">kelvin13ma@gmail.com</a>&gt; wrote:</div><br class="m_2788854386285137500m_-5832259184978187411Apple-interchange-newline"><div><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 29, 2017 at 4:13 PM, Andrew Trick <span dir="ltr">&lt;<a href="mailto:atrick@apple.com" target="_blank">atrick@apple.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><span><br><div><br><blockquote type="cite"><div>On Sep 29, 2017, at 1:23 PM, Taylor Swift &lt;<a href="mailto:kelvin13ma@gmail.com" target="_blank">kelvin13ma@gmail.com</a>&gt; wrote:</div><br class="m_2788854386285137500m_-5832259184978187411m_1404466990729912635Apple-interchange-newline"><div><blockquote class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><div><div>Instead of</div><div><br></div><div>&nbsp;<span class="m_2788854386285137500m_-5832259184978187411m_1404466990729912635Apple-converted-space">&nbsp;</span>buf.intialize(at: i, from: source)</div><div><br></div><div>We want to force a more obvious idiom:</div><div><br></div><div>&nbsp;<span class="m_2788854386285137500m_-5832259184978187411m_1404466990729912635Apple-converted-space">&nbsp;</span>buf[i..&lt;n].intialize(from: source)</div><div><br></div></div></div></div></blockquote><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">The problem with subscript notation is we currently get the<span class="m_2788854386285137500m_-5832259184978187411m_1404466990729912635Apple-converted-space">&nbsp;</span><span style="font-family:monospace,monospace">n</span><span class="m_2788854386285137500m_-5832259184978187411m_1404466990729912635Apple-converted-space">&nbsp;</span>argument from the<span class="m_2788854386285137500m_-5832259184978187411m_1404466990729912635Apple-converted-space">&nbsp;</span><span style="font-family:monospace,monospace">source</span><span class="m_2788854386285137500m_-5832259184978187411m_1404466990729912635Apple-converted-space">&nbsp;</span>argument. So what would really have to be written is<span class="m_2788854386285137500m_-5832259184978187411m_1404466990729912635Apple-converted-space">&nbsp;</span><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-family:monospace,monospace">buf[i ..&lt; i + source.count].initialize(from: source)<span class="m_2788854386285137500m_-5832259184978187411m_1404466990729912635Apple-converted-space">&nbsp;</span></span><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">which is a lot more ugly and redundant. One option could be to decouple the count parameter from the length of the source buffer, but that opens up the whole can of worms in which length do we use? What happens if<span class="m_2788854386285137500m_-5832259184978187411m_1404466990729912635Apple-converted-space">&nbsp;</span><span style="font-family:monospace,monospace">n - i</span><span class="m_2788854386285137500m_-5832259184978187411m_1404466990729912635Apple-converted-space">&nbsp;</span>is less than or longer than<span class="m_2788854386285137500m_-5832259184978187411m_1404466990729912635Apple-converted-space">&nbsp;</span><span style="font-family:monospace,monospace">source.count</span>? If we enforce the precondition that<span class="m_2788854386285137500m_-5832259184978187411m_1404466990729912635Apple-converted-space">&nbsp;</span><span style="font-family:monospace,monospace">source.count == n - i</span>, then this syntax seems horribly redundant.<span class="m_2788854386285137500m_-5832259184978187411m_1404466990729912635Apple-converted-space">&nbsp;</span></div></div></blockquote></div><br></span><div>Sorry, a better analogy would have been:</div><div><br></div><div><div style="word-wrap:break-word;line-break:after-white-space"><div><div><div>&nbsp;buf[i...].intialize(from: source)</div><div><br></div><div>Whether you specify the slice’s end point depends on whether you want to completely initialize that slice or whether you’re just filling up as much of the buffer as you can. It also depends on whether `source` is also a buffer (of known size) or some arbitrary Sequence.</div><div><br></div><div>Otherwise, point &nbsp;taken.</div><div><br></div><div>-Andy</div></div></div></div></div></div></blockquote><div><br></div><div>After thinking about this more, one-sided ranges might provide just the expressivity we need. What if:</div><div><br></div><div><span style="font-family:monospace,monospace"> buf[offset...].initialize(from<wbr>: source) // initializes source.count elements from source starting from offset</span></div><div><span style="font-family:monospace,monospace"><br></span></div><div><span style="font-family:monospace,monospace">buf[offset ..&lt; endIndex].initialize(from: source) // initializes up to source.count elements from source starting from offset<br></span></div><div><br></div><div><br></div></div>The one sided one does not give a full initialization guarantee. The two sided one guarantees the entire segment is initialized. </div></div></div></blockquote><div><br></div><div>In every other context, x[i...] is equivalent to x[i..&lt;x.endIndex]</div><div><br></div><div>I don't think breaking that precedent is a good idea.</div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra">For move operations, the one sided one will fully deinitialize the source buffer while the two sided one will only deinitialize <span style="font-family:monospace,monospace">endIndex - offset</span> elements. <br></div></div>
</div></blockquote></div><br><div>
—<br>-Dave<br></div></div></blockquote><br><div>well since people want to use subscript notation so much we need some way of expressing case 1. writing both bounds in the subscript seems to imply a full initialization (and thus partial movement) guarantee.</div></div></div></blockquote><br></div></div></div><div>Yes, I understood your reasoning.&nbsp; Do you understand why I still don't want to proceed in that direction?</div><br><div>
—<span class="m_2788854386285137500HOEnZb"><font color="#888888"><br>-Dave<br><br><br><br><br>
</font></span></div>
<br></div></blockquote></div><br></div>
</div></blockquote></div><br></div></div><div>
—<span class="HOEnZb"><font color="#888888"><br>-Dave<br><br><br><br><br>
</font></span></div>
<br></div></div></div></blockquote></div><br></div>
</div></blockquote></body></html>