Why is std.algorithm.reduce impure?
H. S. Teoh
hsteoh at quickfur.ath.cx
Tue Mar 6 15:02:33 PST 2012
On Tue, Mar 06, 2012 at 03:00:16PM -0800, H. S. Teoh wrote:
[...]
> But why can't 'this' be const? For example, why does the compiler
> reject this:
>
> class A {
> int[] data;
> pure const int sum() {
> return reduce!"a*b"(data);
> }
> }
>
> I'm not modifying data at at all, so why should it be an error?
[...]
Actually, nevermind that. Looks like a compiler bug that got fixed in
dmd, but hasn't been pulled into gdc yet. I'll just have to be patient.
:-)
T
--
A mathematician is a device for turning coffee into theorems. -- P. Erdos
More information about the Digitalmars-d-learn
mailing list