title: Data ranged subscribe strange behavior
body: <p>I was playing with swift's <code>Data</code> in the following a small code:</p>
  
  <pre class="lang-swift prettyprint-override"><code>var d = Data(count: 10)
  d[5] = 3
  let d2 = d[5..&lt;8]
  print("\(d2[0])")
  </code></pre>
  
  <p>To my surprise, this code throws exception on <code>print()</code> while the following code does not:</p>
  
  <pre class="lang-swift prettyprint-override"><code>var d = Data(count: 10)
  d[5] = 3
  let d2 = d.subdata(in: 5..&lt;8)
  print("\(d2[0])")
  </code></pre>
  
  <p>I somehow understand why this happens, but I don't get why this is designed like this. When I use <code>subdata()</code> I get a whole copy of range, so indexing is valid from <code>0</code>. But when I use range subscribe <code>[]</code>, I get access to the requested range while indexing is the same as before. So in my first example <code>d2[5]</code> is <code>3</code>.</p>
  
  <p>But I wonder why it is designed like this? I don't want to make a copy of my data by using <code>subdata()</code> method. I just wanted to access a portion of my data with better indexing.</p>
  
  <p>This is especially creates unexpected behaviors if you pass it to a function. For example, following code creates unexpected results and exceptions and you may not find out easily why:</p>
  
  <pre class="lang-swift prettyprint-override"><code>func testit(idata: Data) {
      if idata.count &gt; 0 {
          print("\(idata.count)")
          print("\(idata[0])")
      }
  }
  //...
  var d = Data(count: 10)
  d[5] = 3
  let d2 = d[5..&lt;8]
  testit(idata: d2)
  </code></pre>
  
  <p>This code is really strange. Because if you debug your code, you see that <code>print("\(idata.count)")</code> prints <code>3</code> as size of <code>idata</code> which is correct, but accessing it with <code>idata[0]</code> creates exception.</p>
  
  <p>Is there any reason for this design? I was expecting that I could access resulting <code>Data</code> from subscribe starting index 0 while it is not true. Can I do this without using <code>subdata()</code> which creates copy of data or using additional arguments to pass base of data slice?</p>