On 2012-28-13 17:12, d coder <[email protected]> wrote:

I do not know if I am missing something but consider:

struct Foo {
  int r;
  int i;
  bool get() {
    return true;  // always return true
  }
  alias get this;
}

So I am wondering how it would be possible to construct Foo from a bool?
Otherwise how would the compiler be able to figure out in what scenarios
reverse conversion is possible and is intended.

get is not an lvalue. If you attempt this today:

struct S {
    bool get() @property {
        return true;
    }
    alias get this;
}

S s;
s = false;

you should get a nice compile error. This would of course also apply in
this new situation. Now, this:

struct S {
    bool get() @property {
        return true;
    }
    void get(bool value) @property {
    }
    alias get this;
}

S s;
s = false;

should work. Given this, I believe default-constructing the value, then
applying normal alias this rules, makes the most sense.

--
Simen

Reply via email to