How is chunkBy supposed to behave on copy

Steven Schveighoffer schveiguy at gmail.com
Thu Mar 19 14:46:39 UTC 2020


On 3/19/20 10:28 AM, Dukc wrote:
> On Thursday, 19 March 2020 at 14:11:20 UTC, Steven Schveighoffer wrote:
>>
>> If you want to copy a forward range use save. Anything else is 
>> possible to break in an implementation detail later.
>>
> 
> Ouch - my code has to be totally broken. And I don't think I'm the only 
> one.

You are not the only one. Almost all range functions are tested with and 
use arrays, which do exactly the same for .save or copying. The reason 
why `save` is such a bad solution is because there is generally no 
penalty for ignoring it (until there is).

The only way to "fix" this IMO is to migrate to a system where standard 
(non-forward) input ranges are not copyable, and deprecate save. It 
likely will never happen.

-Steve


More information about the Digitalmars-d mailing list