D1 operator overloads have been deprecated.

Jonathan M Davis newsgroup.d at jmdavisprog.com
Fri Jul 12 01:13:24 UTC 2019


On Thursday, July 11, 2019 2:29:19 PM MDT Basile B. via Digitalmars-d wrote:
> On Thursday, 11 July 2019 at 17:58:50 UTC, uranuz wrote:
> > In change log of nightly builds I see that:
> > `D1 operator overloads have been deprecated`
> > The major concern about it is that D2 style operators are
> > template functions. And template functions cannot be virtual.
>
> Nice catch...
>
> > Does it mean that we shall not be able to decalare operators in
> > classes and interfaces that could be overloaded in terms of OOP.
>
> It rather looks like a big whoopsie. Nobody has thought to this
> case during the review stage[1]. I don't know if the change would
> have been accepted otherwise, even if they were not documented
> anymore.
>
> [1] https://github.com/dlang/dmd/pull/10130

It was decided years ago that the old, non-templated overloaded operators
would be removed from the language, and it was well-known that if you then
wanted virtual operator overloading, you'd need to forward to a protected,
virtual function. Most user-defined types in D are structs anyway, and it's
a simple workaround when you need virtual operator overloading with classes.
I actually thought that the old operators had been fully removed quite some
time ago, but I guess that it's on the list of stuff where we clearly
decided that it was going away, but no one got around to actually
deprecating it.

- Jonathan M Davis





More information about the Digitalmars-d mailing list