Recently lot of work has being done about "inout", and I think it is now usable 
in D2.

So this has made me ask how much needs to be done (in D language and/or Phobos) 
to allow the correct compilation of exactly this useless demo program (I think 
it is correct):


import std.algorithm, std.range, std.array;
auto foo(in int[] data) pure {
    immutable int n = count!q{ a % 2 == 1 }(data);
    return map!q{ a * 2 }([n, n+1, n+2]);
}
void main() {
    auto a = array(iota(10));
    assert(equal(foo(a), [10, 12, 14]));
}


Currently count can't digest a const array and that map isn't pure. It runs if 
you remove "in" and "pure".

Once this program compiles I think std.algorithm becomes significantly more 
usable.

Bye,
bearophile

Reply via email to