<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>Yup, I just tested on <a href="http://scastie.org">scastie.org</a>, extending my earlier example:</div><div><br></div><div><div class="line number1 index0 alt2" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">class</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">Coll(</code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">val</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">elements</code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">:</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">List[Int]) {</code></span></font></div><div class="line number2 index1 alt1" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code> </span></font></div><div class="line number3 index2 alt2" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">case</code> <code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">class</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">Index(</code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">val</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">value</code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">:</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">Int)</code></span></font></div><div class="line number4 index3 alt1" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code> </span></font></div><div class="line number5 index4 alt2" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">def</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">firstIndex</code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">:</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">Index </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">=</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">Index(</code><code class="scala value" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">0</code><code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">)</code></span></font></div><div class="line number6 index5 alt1" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code> </span></font></div><div class="line number7 index6 alt2" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">def</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">get(index</code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">:</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">Index) </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">=</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">elements(index.value)</code></span></font></div><div class="line number8 index7 alt1" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code> </span></font></div><div class="line number9 index8 alt2" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">def</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">slice(start</code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">:</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">Index) </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">=</code> <code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">new</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">Slice(start.value)</code></span></font></div><div class="line number10 index9 alt1" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code> </span></font></div><div class="line number11 index10 alt2" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">class</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">Slice(</code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">val</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">start</code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">:</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">Int) {</code></span></font></div><div class="line number12 index11 alt1" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">def</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">firstIndex</code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">:</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">Index </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">=</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">Index(start)</code></span></font></div><div class="line number13 index12 alt2" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">def</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">get(index</code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">:</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">Index) </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">=</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">elements(index.value)</code></span></font></div><div class="line number14 index13 alt1" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code><code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">}</code></span></font></div><div class="line number15 index14 alt2" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code> </span></font></div><div class="line number16 index15 alt1" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; background-color: rgba(255, 255, 255, 0);"><font face="UICTFontTextStyleTallBody">}</font></code></div><div class="line number17 index16 alt2" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code> </span></font></div><div class="line number18 index17 alt1" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">object</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">Main </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">extends</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">App {</code></span></font></div><div class="line number19 index18 alt2" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code> </span></font></div><div class="line number20 index19 alt1" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">val</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">a </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">=</code> <code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">new</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">Coll(List(</code><code class="scala value" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">1</code><code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">, </code><code class="scala value" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">2</code><code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">, </code><code class="scala value" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">3</code><code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">))</code></span></font></div><div class="line number21 index20 alt2" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">val</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">b </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">=</code> <code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">new</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">Coll(List(</code><code class="scala value" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">1</code><code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">, </code><code class="scala value" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">2</code><code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">, </code><code class="scala value" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">3</code><code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">))</code></span></font></div><div class="line number22 index21 alt1" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code> </span></font></div><div class="line number23 index22 alt2" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">val</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">i </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">=</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">a.firstIndex</code></span></font></div><div class="line number24 index23 alt1" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code> </span></font></div><div class="line number25 index24 alt2" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code><code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">a.get(i)</code></span></font></div><div class="line number26 index25 alt1" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code><code class="scala comments" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">// b.get(i) // type error</code></span></font></div><div class="line number27 index26 alt2" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code> </span></font></div><div class="line number28 index27 alt1" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">val</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">s </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">=</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">a.slice(a.firstIndex)</code></span></font></div><div class="line number29 index28 alt2" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code><code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">s.get(a.firstIndex) </code><code class="scala comments" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">// allowed!</code></span></font></div><div class="line number30 index29 alt1" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code> </span></font></div><div class="line number31 index30 alt2" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">val</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">s</code><code class="scala value" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">2</code> <code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">=</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">b.slice(b.firstIndex)</code></span></font></div><div class="line number32 index31 alt1" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code><code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">s</code><code class="scala value" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">2</code><code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">.get(b.firstIndex)</code></span></font></div><div class="line number33 index32 alt2" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code><code class="scala comments" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">// s2.get(a.firstIndex) // type error</code></span></font></div><div class="line number34 index33 alt1" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><span style="background-color: rgba(255, 255, 255, 0);"> </span></div><div class="line number35 index34 alt2" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><font face="UICTFontTextStyleTallBody"><span style="background-color: rgba(255, 255, 255, 0);"><code class="scala spaces" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;"> </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">val</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">indices</code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">:</code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">List[a.Index] </code><code class="scala keyword" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; font-weight: bold !important;">= </code> <code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit;">List(a.firstIndex)</code></span></font></div><div class="line number36 index35 alt1" style="margin: 0px; padding: 0px; border: 0px; outline: 0px;"><code class="scala plain" style="margin: 0px; padding: 0px; border: 0px; outline: 0px; font-style: inherit; background-color: rgba(255, 255, 255, 0);"><font face="UICTFontTextStyleTallBody">}</font></code></div></div><div><br></div><div>Note the last line declaring a list of indices of collection 'a'.</div><div><br></div><div>-Thorsten </div><div><br></div><div><br>Am 19.04.2016 um 10:01 schrieb Thorsten Seitz via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>>:<br><br></div><blockquote type="cite"><div><span></span><br><span></span><br><blockquote type="cite"><span>Am 18.04.2016 um 23:54 schrieb Dave Abrahams via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>>:</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>on Sat Apr 16 2016, Thorsten Seitz <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Am 15.04.2016 um 23:19 schrieb Dmitri Gribenko via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>>:</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>On Fri, Apr 15, 2016 at 1:30 PM, Stephan Tolksdorf <<a href="mailto:st@quanttec.com">st@quanttec.com</a>> wrote:</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>On 2016-04-12 Dmitri Gribenko via swift-evolution wrote:</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Not even to mention that</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>indices are valid only in context of a particular collection instance,</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>so in this model you could validate an index against one collection</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>and use it with another one.</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>The proposal requires Index values to be Comparable. Does that mean that</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>indices from different collection instances should be comparable i.e. have a</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>strict total order?</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>No, comparing indices from unrelated instances produces unspecified</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>results (incl. traps).</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Path dependent types as used in Scala would allow making this</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>distinction type safe (see</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span><a href="http://docs.scala-lang.org/tutorials/tour/inner-classes">http://docs.scala-lang.org/tutorials/tour/inner-classes</a> or</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span><a href="http://danielwestheide.com/blog/2013/02/13/the-neophytes-guide-to-scala-part-13-path-dependent-types.html">http://danielwestheide.com/blog/2013/02/13/the-neophytes-guide-to-scala-part-13-path-dependent-types.html</a>)</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>by allowing the index type to be rooted at the instance.</span><br></blockquote></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>Wouldn't that also rule out useful designs, as in those where indices</span><br></blockquote><blockquote type="cite"><span>into one collection are stored in another?</span><br></blockquote><span></span><br><span>This should still be possible:</span><br><span></span><br><span>val a: Collection<T> = ...</span><br><span>val indices: List<a.Index> = ...</span><br><span></span><br><span>As 'a.Index' is just a normal type it should be possible to declare a collection containing elements of just that type (I haven't tried it out, yet, though, as I currently have no access to a development machine).</span><br><span></span><br><span>-Thorsten </span><br><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>