On Wed, Oct 17, 2012 at 06:58:52PM +0200, Jacob Carlborg wrote: > On 2012-10-17 17:45, Jonathan M Davis wrote: > > >Well, what would you expect? Ranges are consumed when you iterate > >over them. So, if an container is a range, it will be consumed when > >you iterate over it. That's the way that it _has_ to work given how > >ranges work, and that's why you overload opSlice to return a range > >which is iterated over rather than making the container itself a > >range. > > How does this work with built-in arrays? [...]
If I understand it correctly, arrays work because when you pass an array to a range function, you're actually passing a slice of it to the function. That slice gets consumed, but the original array is unchanged. T -- A linguistics professor was lecturing to his class one day. "In English," he said, "A double negative forms a positive. In some languages, though, such as Russian, a double negative is still a negative. However, there is no language wherein a double positive can form a negative." A voice from the back of the room piped up, "Yeah, yeah."