Property functions are used wrong by a compiler when it needs to get and set a value at the same time:

import std.stdio;

struct A {
    @property int value() const {
        return value_;
    }

    @property ref int value(int v) {
                value_ = v;
                return value_;
    }

private:
        int value_;
}

int main(string[] args) {
        A a;
        a.value += 20; // <<<<< Error: a.value() is not an lvalue
        return 0;
}


It's a very inconvenient. Why don't just call a getter and then a setter functions in such cases? I found the D language specification and it doesn't bother to explain how properties should behave in such cases. Is there a full language specification somewhere? Also, I've googled a little and found a similar topic from 2012 (http://forum.dlang.org/thread/srhwzxgpiqucknche...@forum.dlang.org). So, since 2012 nobody cared about it? What a shame! Even a D Wiki page with properties discussion (https://wiki.dlang.org/Property_Discussion_Wrap-up) gives an example of property usage, which can't be compiled by the latest version of dmd:

a.weeks++;
a.weeks -=2;

Is there a chance, that this weird behavior will be fixed in the near future? What can I do to help fix it?

Reply via email to