Why is std.algorithm.reduce impure?
Jonathan M Davis
jmdavisProg at gmx.com
Wed Mar 7 10:57:53 PST 2012
On Wednesday, March 07, 2012 17:29:24 Simen Kjærås wrote:
> On Wed, 07 Mar 2012 01:41:22 +0100, Jonathan M Davis <jmdavisProg at gmx.com>
>
> wrote:
> > It really takes very little for something to be impure, and optimizations
> > often do it, because they end up using low-level constructs which aren't
> > pure
> > - some of which could be but aren't and others which probably can't be.
>
> Just so this is clear - no optimization of the compiler is going to change
> the purity of a function. An optimization on the part of the programmer
> (like using appender) might, though.
I didn't say that it did, though maybe I wasn't clear enough. Optimizations of
the _algorithms_ involved can make a function impure - such as use Appender
instead of ~= when building arrays.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list