On 20/09/13 20:53, H. S. Teoh wrote:
Sad to say, I encountered a good number of Phobos bugs caused by the
conflation between built-in arrays and ranges. Code would inadvertently
assume array behaviour on ranges, and break when you pass in a non-array
range. Some of these have been fixed; I'm pretty sure there are still
more lurking around.

In my case, I discovered a number of bugs that stemmed from unittests where the default range type used was an array.

In that case, it wasn't so much the conflation of range and container, but the fact that arrays are random-access ranges and so have the maximal set of range properties -- so code that _theoretically_ should have worked with input ranges was actually failing, because it wasn't being tested.

Actually, it helps you understand the const(T[]) case. To iterate over a
const array, you need a range over it (i.e., a slice); and indeed,
writing arr[] on an array of type const(T[]) gives you a tail-const
slice of type const(T)[], which *is* an iterable range.

The confusion really just stems from the conflation between T[] and a
range over T[] in the non-const case.

Ahh, OK.  You're right, that does help.  Thank you! :-)

Reply via email to