www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - D1 operator overloading in D2

reply ketmar <ketmar ketmar.no-ip.org> writes:
it's still working. moreover, it is used in Phobos! and yet it's not=20
documented anywhere. what i want to know is whether they will be removed=20
for good, or brought back and properly documented? the current situation=20
is awful: compiler has special treatment for some aggregate members, but=20
nothing in documentation tells you that.=
Mar 29 2015
parent reply Steven Schveighoffer <schveiguy yahoo.com> writes:
On 3/30/15 1:42 AM, ketmar wrote:
 it's still working. moreover, it is used in Phobos! and yet it's not
 documented anywhere. what i want to know is whether they will be removed
 for good, or brought back and properly documented? the current situation
 is awful: compiler has special treatment for some aggregate members, but
 nothing in documentation tells you that.
They technically can be removed for good, because an operator template can now be an alias (this was pretty recent, maybe 1 year ago?). There is still one thing that doesn't work right I think -- covariance. But doing so would break all code that uses it. I think at the very least, Phobos should replace all D1-style operators with D2 style. Dogfooding and all. Originally when the "yay, look at these new template-style operators" was posted, it was imagined that one could do: mixin(generateD2Operators); in your aggregate, and the links from the new style operators to the old style would give you an upgrade path without having to rewrite all your operators. This really wasn't possible until the alias update. But maybe it's time to add this to std.typecons. I think at the very least we should provide a link to the D1 documentation and say that "D1 operators overloads are still supported, but their support is not guaranteed to continue, please use D2 operators wherever possible." Clearly, there is some work that should be done. I agree that if you come across old code, and you are unaware of the old style operators, you will be super-confused as to how the operators are even working. That can be very annoying. I'll put in a doc PR to reference the D1 documentation. -Steve
Mar 30 2015
next sibling parent ketmar <ketmar ketmar.no-ip.org> writes:
On Mon, 30 Mar 2015 11:25:01 -0400, Steven Schveighoffer wrote:

 On 3/30/15 1:42 AM, ketmar wrote:
 it's still working. moreover, it is used in Phobos! and yet it's not
 documented anywhere. what i want to know is whether they will be
 removed for good, or brought back and properly documented? the current
 situation is awful: compiler has special treatment for some aggregate
 members, but nothing in documentation tells you that.
They technically can be removed for good, because an operator template can now be an alias (this was pretty recent, maybe 1 year ago?). There is still one thing that doesn't work right I think -- covariance. =20 But doing so would break all code that uses it. I think at the very least, Phobos should replace all D1-style operators with D2 style. Dogfooding and all. Originally when the "yay, look at these new template-style operators" was posted, it was imagined that one could do: =20 mixin(generateD2Operators); =20 in your aggregate, and the links from the new style operators to the old style would give you an upgrade path without having to rewrite all your operators. This really wasn't possible until the alias update. But maybe it's time to add this to std.typecons. =20 I think at the very least we should provide a link to the D1 documentation and say that "D1 operators overloads are still supported, but their support is not guaranteed to continue, please use D2 operators wherever possible." =20 Clearly, there is some work that should be done. I agree that if you come across old code, and you are unaware of the old style operators, you will be super-confused as to how the operators are even working. That can be very annoying. =20 I'll put in a doc PR to reference the D1 documentation. =20 -Steve
i actually replaced that with D2 opovers in Phobos, and it passes=20 unittests, so i can create ER in bugzilla with patch for someone to turn=20 it into PR.=
Mar 30 2015
prev sibling next sibling parent "Kagamin" <spam here.lot> writes:
Wow, it's quite old, 2.041.
Mar 30 2015
prev sibling next sibling parent ketmar <ketmar ketmar.no-ip.org> writes:
On Mon, 30 Mar 2015 11:25:01 -0400, Steven Schveighoffer wrote:

here is ER with patches:
https://issues.dlang.org/show_bug.cgi?id=3D14382

sorry for breaking my promise of not making ERs anymore. ;-)=
Mar 30 2015
prev sibling parent Steven Schveighoffer <schveiguy yahoo.com> writes:
On 3/30/15 11:25 AM, Steven Schveighoffer wrote:

 I'll put in a doc PR to reference the D1 documentation.
https://github.com/D-Programming-Language/dlang.org/pull/953 -Steve
Apr 03 2015