On 11/07/2012 21:45, Steven Schveighoffer wrote:
On Wed, 11 Jul 2012 15:14:19 -0400, deadalnix <deadal...@gmail.com> wrote:

On 11/07/2012 20:53, Steven Schveighoffer wrote:
On Wed, 11 Jul 2012 14:21:24 -0400, Steven Schveighoffer
<schvei...@yahoo.com> wrote:


It also seems to allow abuses. For example:

class A
{
private int _x;
public @property x() const { return _x; }
}

class B : A
{
private int _x2;
public @property x() { return _x2++; }
}


Another abuse:

const(B) b = new B;
// auto bx = b.x; // oops, compiler error
const(A) a = b;
auto bx = a.x;

-Steve

This shouldn't be a compiler error. An object of type B is 100% of
time mutable now.

According to my code, b is const, and never was mutable.

If you are saying that I should be able to call b.x, then this proposal
is even worse than I thought! I have no idea what const means in this
world.

-Steve

Const is a bridge between mutable and immutable world. The guarantee proposed with const is that it never mutate an immutable data. This is slightly different than how const is implemented actually, but still ensure that no immutable data is muted.

Reply via email to