taskPool.reduce vs algorithm.reduce

Paul Backus snarwin at gmail.com
Wed Jul 11 09:59:38 UTC 2018


On Wednesday, 11 July 2018 at 08:31:30 UTC, Dorian Haglund wrote:
>
> But it fails to compile (with gdc 8.1.0, dmd v2.081) 
> complaining that
>
> template instance reduce!(f) cannot use local 'f' as parameter 
> to non-global template reduce(functions...)

Congratulations! You've just run into issue 5710 [1], one of D's 
most annoying known bugs.

[1]: https://issues.dlang.org/show_bug.cgi?id=5710

> The snippet above compiles with the reduce function from 
> std.algorithm.
>
> [...]
>
> Why the interface difference between std.algorithm's reduce and 
> taskPool.reduce ?

std.algorithm.reduce is a free function, so it can accept 
delegates as template parameters. taskPool.reduce is a member 
function, so it can't.


More information about the Digitalmars-d-learn mailing list