On 05/29/2010 02:51 PM, Philippe Sigaud wrote:
  Steve:
 > Arguably, Take should never support back and popBack.
 > If you have a random access range, why wouldn't you just do r[0..3]?

Because your range may not have opSlice defined. And is such a slice
always lazy?

I think the correct answer is that with take(r, 5) you take maximum 5 elements from any range (more general), whereas with r[0 .. 5] you take exactly 5 elements from a range defining opSlice (most often, random access) - which is a more specialized function.

There's a tacit rule that has r.opSlice(a, b) return the same type as r itself.

I'm not sure if take does that already, but it should simply morph into opSlice() if opSlice() is available. No need to use another layer when opSlice does what you need.


Andrei
_______________________________________________
phobos mailing list
[email protected]
http://lists.puremagic.com/mailman/listinfo/phobos

Reply via email to