View mode: basic / threaded / horizontal-split · Log in · Help
March 06, 2012
Why is std.algorithm.reduce impure?
Why is std.algorithm.reduce not marked pure? It makes it impossible to
do things like this:

	pure const int product(int[] args) {
		return reduce!"a * b"(args);
	}


T

-- 
Life is unfair. Ask too much from it, and it may decide you don't deserve what you have now either.
March 06, 2012
Re: Why is std.algorithm.reduce impure?
On Tuesday, 6 March 2012 at 22:39:20 UTC, H. S. Teoh wrote:
> Why is std.algorithm.reduce not marked pure?

It doesn't have to be - templates are inferred to be
pure or not.

If you take the const off that signature, your example
works in today's dmd.
Top | Discussion index | About this forum | D home