Immutable separator to join() doesn't work
so
so at so.so
Mon Jul 11 14:37:04 PDT 2011
On Tue, 12 Jul 2011 00:01:55 +0300, Jonathan M Davis <jmdavisProg at gmx.com>
wrote:
> The solution is to fix template instantiation so that it's smarter when
> dealing with static arrays and const or immutable arrays:
> http://d.puremagic.com/issues/show_bug.cgi?id=6148
>
> It's a language issue, not a design issue. Making ranges function like
> slists
> (with head and tail or car and cdr) would be almost certainly be too
> inefficient (particularly for ranges where save is not super cheap,
> though
> it's at least supposed to be fairly cheap). Immutability might be nice,
> but it
> does have its costs, and in this case, D's templates aren't currenly
> smart
> enough to use immutable(E)[] instead of immutable(E[]). And it's not like
> immutable ranges are going to work with non-array ranges anyway, so it's
> arguably a good idea to just expect immutable and const ranges to not
> work
> anyway.
There is a simple workaround for this type of ranges that are like
iterators, which we know the beginning and the end.
We can improve isForwardRange!R by adding a line hasForwardRange!R. If it
does have, we return an adaptor which gives us a mutable range.
Good thing is because the original range is mutable we don't need to worry
about anything else.
More information about the Digitalmars-d
mailing list