Is there a way to make sure a delegate only reads state, without changing it? I tried annotating the delegate as const, but that does not seem to work.

```D
void main()
{
    import std.stdio : writeln;
    auto r = [0,1,2,3];

auto f = delegate() const // Compiles even though we are changing r
    {
        import std.array : popFront;
        r.popFront;
    };

    r.writeln; // [0,1,2,3]
    f();
    r.writeln; // [1,2,3]
}
```


Reply via email to