std.v2020.algorithm etc[ WAS: Is run.d going to be expand for runtime and the phobos library?]

Paul Backus snarwin at gmail.com
Mon Jun 22 14:20:56 UTC 2020


On Monday, 22 June 2020 at 12:15:39 UTC, Steven Schveighoffer 
wrote:
>
> My question wasn't about how such a thing could be implemented, 
> but how it works with const ranges.
>
> foreach(x; someConstRange) I think wouldn't be possible. I 
> think you'd have to recurse:
>
> void process(const Range r)
> {
>    subProcess(r.front);
>    process(r.rest);
> }
>
> The point is to question the statement "so that we can have 
> `const` and `immutable` ranges".
>
> Sure, we could implement recursive versions of find, etc. I 
> don't know if that's worth it.
>
> -Steve

Well, currently, range algorithms can't work with const ranges 
*at all*, recursively or iteratively. So from a user perspective, 
this would be a strict improvement on the status quo.


More information about the Digitalmars-d mailing list