[phobos] phobos commit, revision 1566
Andrei Alexandrescu
andrei at erdani.com
Sun May 30 06:39:22 PDT 2010
On 05/30/2010 01:39 AM, Philippe Sigaud wrote:
> On Sat, May 29, 2010 at 23:17, Andrei Alexandrescu <andrei at erdani.com
> <mailto:andrei at erdani.com>> wrote:
>
> 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.
>
>
> No, it does not do that already. OK, I'm a pain, but what if the range
> does not know its length? How do you know if r[0..n] is OK?
Just like every other range in std.range, you support various primitives
depending on what your wrapped range supports. Per your question, in
this case, if the range doesn't know its length but does support r[0 ..
n], you conservatively wrap it with Take.
But I have to say that would be a pretty bizarre range.
Andrei
More information about the phobos
mailing list