All right, all right! Interim decision regarding qualified Object methods
Jonathan M Davis
jmdavisProg at gmx.com
Thu Jul 12 12:26:28 PDT 2012
On Thursday, July 12, 2012 21:11:54 Jacob Carlborg wrote:
> On 2012-07-12 16:28, 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.)
> >
> > ...But, I would never opposed to advancing toward the better language
> > design.
> >
> > Kenji Hara
>
> I would have thought that that already worked.
The recently added attribute inferrence for overridden functions in derived
types makes it impossible to have a non-const overload of a const function.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list