Walter Bright:

http://wiki.dlang.org/DIP60

Start on implementation:

https://github.com/D-Programming-Language/dmd/pull/3455

Currently this code doesn't compile because the lambda allocates the closure on the heap:

void main() @nogc {
    import std.algorithm: map;
    int[3] data = [1, 2, 3];
    immutable int x = 3;
    auto result = data[].map!(y => y * x);
}


test.d(1,6): Error: function D main @nogc function allocates a closure with the GC

Such kind of code is common, so a good amount of range-based code can't be @nogc.

-----------

In the meantime the good Kenji has created a patch for missing semantics:
https://github.com/D-Programming-Language/dmd/pull/3493

Bye,
bearophile

Reply via email to