D1 operator overloading in D2

ketmar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Mar 30 08:34:55 PDT 2015


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.
> 
> 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

i actually replaced that with D2 opovers in Phobos, and it passes 
unittests, so i can create ER in bugzilla with patch for someone to turn 
it into PR.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20150330/ff0d9693/attachment.sig>


More information about the Digitalmars-d-learn mailing list