How is chunkBy supposed to behave on copy

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Mar 18 19:23:17 UTC 2020


On Wed, Mar 18, 2020 at 02:55:35PM -0400, Steven Schveighoffer via Digitalmars-d wrote:
> On 3/18/20 2:30 PM, H. S. Teoh wrote:
[...]
> > 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).
[...]

Fair enough.

Still, I think we should totally detect hasSlicing, or at least built-in
arrays, and default that to the slicing implementation instead.


T

-- 
Bomb technician: If I'm running, try to keep up.


More information about the Digitalmars-d mailing list