On Monday, 9 February 2015 at 12:39:06 UTC, Marc Schütz wrote:
On Monday, 9 February 2015 at 11:38:23 UTC, Jakob Ovrum wrote:
On Monday, 9 February 2015 at 11:37:23 UTC, Jakob Ovrum wrote:
std.array.join is strongly pure (with appropriate template arguments), so its return value is implicitly convertible to immutable.

Err, implicitly convertible to *mutable*. It goes both ways.

It does? Not according to my tests. And it would be bad if it did, because the returned immutable value could actually reside in read-only memory.

join returns a mutable array, that can be implicitly casted to immutable if join is pure.

BTW, that was hard to figure out, because

ElementEncodingType!(ElementType!RoR)[] join(RoR, R)(RoR ror, R sep) if (isInputRange!RoR && isInputRange!(Unqual!(ElementType!RoR)) && isInputRange!R && is(Unqual!(ElementType!(ElementType!RoR)) == Unqual!(ElementType!R))); ElementEncodingType!(ElementType!RoR)[] join(RoR)(RoR ror) if (isInputRange!RoR && isInputRange!(Unqual!(ElementType!RoR)));

and ElementEncodingType is not linked.

That would read so much better as

let
   alias C = ElementEncodingType!(ElementType!RoR)
   alias ERT = Unqual!(ElementType!RoR)
   alias ET = ElementType!ERT
in
   C[] join(RoR, R)(RoR ror, R sep)
   if(  isInputRange!(RoR) && isInputRange!ERT && isInputRange!R
     && is(ET == ElementType!R))

   C[] join(RoR)(RoR ror)
     if( isInputRange!RoR) && isInputRange!ERT )


Do our planned ddo[c|x] enhancement make this possible?

Reply via email to