How is chunkBy supposed to behave on copy
Dukc
ajieskola at gmail.com
Thu Mar 19 17:15:51 UTC 2020
On Thursday, 19 March 2020 at 16:01:39 UTC, H. S. Teoh wrote:
>
> The problem is, you *cannot* give any guarantees about copy
> behaviour, because it depends on the behaviour of the incoming
> range. For example, if you pass the output of .byChunk to
> another range algorithm, that second algorithm cannot guarantee
> copy behaviour anymore.
>
> In fact, all you have to do is to wrap a forward range in an
> InputRangeObject (let's say you need to alternate between two
> different range types (but with compatible elements) at
> runtime, then you'll need to do this), and now you have a
> forward range with by-reference semantics that requires the use
> of .save in order to retain its current position.
The documentation would say that the copy behaviour of the range
is the same as the source range has. A guarantee to depend on the
source range is still a guarantee, and definitely better than the
present situation.
More information about the Digitalmars-d
mailing list