I'm trying to put a bit of `pure` and `const`/`immutable` in my code, and I'm getting strange error messages.

Namely, I've a pure function, says `foo` that returns `std.algorithm.joiner(someValue)`:

import std.algorithm: joiner;
auto foo() pure
{
    // some internal calculation
    // creating `someValue`
    return joiner(someValue);
}

DMD tells me `foo` cannot use the impure `joiner`, due to `joiner`'s internal struct (Result) not having pure methods (`empty`/`front`/`popFront`).

Now, it seems obvious why these range methods are not pure (`popFront`, at least). But I don't use them in my function! I just return a lazy range to iterate on other ranges. My own function do not mutate anything, it just creates an object. A mutable value admittedly, but not one with global state.

I know Phobos is not using `pure` as much as it could right now, but I really don't see why it's causing trouble right there.

Reply via email to