All right, all right! Interim decision regarding qualified Object methods

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Jul 12 07:53:04 PDT 2012


On 7/12/12 10:28 AM, kenji hara wrote:
> Is this really need?
>
> The four const operators in Object should not block the user-defined
> mutable operators.
>
> // My purpose for 2.060 release
> class C {
>    override opEquals(const Object o) const { ... } // or just alias
> super.opEquals opEquals;
>    bool opEquals(Object o) { ... } // add overload for mutable object comparison
> }
>
> auto c1 = new C(), c2 = new C2();
> c1 == c2;   // the both hand side is mutable, so mutable opEquals will run
>
> In git head, it is not disallowed, but it is a *compiler bug*.
> To fix the problem, I have a pull request for dmd.
> https://github.com/D-Programming-Language/dmd/pull/1042
> (The pull will kill attribute inference for const, but I think it is
> unnecessary for D.)

I didn't know of that, thanks.

> ....But, I would never opposed to advancing toward the better language design.

Thanks for being so helpful and flexible! Let's discuss matters a little 
more in this forum before making a decision.


Andrei


More information about the Digitalmars-d mailing list