<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 Dec 18, 2015, at 4:42 AM, Amir Michail 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=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Examples:<div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class="">&gt;&gt;&gt; l=[1,2,3,4,5]</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class="">&gt;&gt;&gt; l[-1]</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class="">5</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class="">&gt;&gt;&gt; l[-2]</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class="">4</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class="">&gt;&gt;&gt; l[2:4]</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class="">[3, 4]</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class="">&gt;&gt;&gt; l[2:]</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class="">[3, 4, 5]</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class="">&gt;&gt;&gt; l[-2:]</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class="">[4, 5]</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class="">&gt;&gt;&gt; l[:3]</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class="">[1, 2, 3]</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class="">&gt;&gt;&gt; l[::2]</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class="">[1, 3, 5]</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class="">&gt;&gt;&gt; l[::]</div><div style="margin: 0px; font-size: 16px; line-height: normal; font-family: Menlo;" class="">[1, 2, 3, 4, 5]</div></div>
</div></div></blockquote><br class=""></div><div>Accepting negative indices is problematic for two reasons: it imposes runtime overhead in the index operation to check the sign of the index; also, it masks fencepost errors, since if you do foo[m-n] and n is accidentally greater than m, you'll quietly load the wrong element instead of trapping. I'd prefer something like D's `$-n` syntax for explicitly annotating end-relative indexes.</div><div><br class=""></div><div>-Joe</div><br class=""></body></html>