2013/2/23 deadalnix <deadalnix@gmail.com>
On Friday, 22 February 2013 at 18:55:58 UTC, kenji hara wrote:
No, const/inout overload does not intend to solve 'method hiding' problem.

To clarify the situation, I try to explain.

class A {
  void foo() {}
  void foo() const {}
}


You missed the important part. I'm talking about overload, not override. IE, not method hiding.

What you have in class A here is useful for use cases that are now solved by inout (getting ranges/iterator from collection for instance).

What you intend is:

class A {
  void foo() inout { bar() }
  void bar() {}
  void bar() const {}
}
void main() {
  auto ma = new A();
  ma.foo();  // call foo() inout, and bar() is called in it.
  auto ca = new const A();
  ca.foo();  // call foo() inout, and bar() const is called in it.
}

? If so, it is just *impossible*. Inout method does not work as like that.
Inside inout function, all inout qualified objects are treated as like const. In there, you never call mutable method from inout object. It is the inout design.

Kenji Hara