A discussion is building around
https://github.com/D-Programming-Language/phobos/pull/2149, which is a
nice initiative by Walter to allow Phobos users to avoid or control
memory allocation.
First instance of the pull request copied the inputs into an output range.
The second instance (right now) creates an input range that lazily
creates the result. The element type of that range is the encoding type
of the first argument (i.e. char or wchar most of the time). This is
different from string/wstring/etc element-wise iteration because it'll
be done code unit-wise, not code point-wise.
We need a robust idiom for doing such string manipulation without
allocation, for which setExtension is just an example. Going the output
range route has nice things going for it because the output range
decides the encoding in advance and then accepts via put() calls any
encoding, with only the minimum transcoding needed.
However output range means the string operation will be done eagerly,
whereas lazy has advantages (nice piping, saving on work etc).
On the other hand, there's the risk of becoming "more catholic than the
Pope" by insisting on lazy string processing. Most string operations are
eager, and insisting on a general framework for lazy encoded operations
on strings may be an exaggeration.
D{iscuss,estroy}!
Andrei