How is chunkBy supposed to behave on copy
Steven Schveighoffer
schveiguy at gmail.com
Wed Mar 18 18:55:35 UTC 2020
On 3/18/20 2:30 PM, H. S. Teoh wrote:
> It sounds like a good idea, but these days I'm wary of proliferating
> these implementation-detail-based parameters. They're a pain to write,
> a pain to use, and a pain to maintain, and once you have the option
> you're committed to supporting it even if one day you invent a better
> algorithm that completely changes the implementation.
>
> I much rather detect hasSlicing on the incoming range, and switching to
> a better implementation.
The problem is that you don't know what the bottleneck is, only the user
does.
auto r = arr.map!(elem => someHorribleCalculation(elem));
static assert(hasSlicing(typeof(r))); // 2x horrible calculations
The thing I would do is provide the "implementation detail" mechanisms,
but default to something reasonable. It could even change based on
whether slicing is available (the default, that is).
-Steve
More information about the Digitalmars-d
mailing list