Is there any intention to address the issue of the lvalue-ness of "this"? In C++, *this is always an lvalue, even if the member function was called with an rvalue, leading to situations like this:

struct Number
{
    void fix() { if (isnan(x)) x = 0; }
    double x;
}

class Collection(T) {
  ref T opIndex(size_t i) { ... }
  ...
}

void fixAll(Collection!Number c) {
  foreach (i; 0 .. c.length) {
    c[i].fix();
  }
}


Here, if Collection changes to return by non-ref then the fix() call is still valid, silently doing nothing of value. Analogous code in C++ is allowed as well.

Do we intend to fix this as well? I suspect there are use cases where such calls are useful, but I can't think of any right now.

Reply via email to