What did you think about an implicitConversionOp ?

12345swordy alexanderheistermann at gmail.com
Sun Dec 27 15:18:19 UTC 2020


On Sunday, 27 December 2020 at 09:27:05 UTC, Walter Bright wrote:
> I'm speaking here from C++'s experience.

That's the thing isn't it? We don't have to do it the c++ way! 
Other languages done implicit conversions differently than c++, 
which requires further examination.

> Implicit conversion operator overloading is in the category of 
> ideas whose evil nature only becomes apparent after several 
> years:
>
> 1. implicit declaration of variables

That's not a bug, but a good feature. Just have a "one and only 
one implicit conversion" for variables, then problem solved.
>
> 2. macros

I think we agree that c macros is a bad idea. Templates on the 
other hand just needed type restrictions, to prevent nonsense if 
desired. Type functions are very promising on this.


> 3. operator overloading for non-arithmetic purposes

Can this be said regarding arithmetic operator overloading in 
general?

> 4. implicit conversion operator overloads

Which should have been opt-in not opt-out. The overload handing 
should be left up to the programmer not to the compiler.




More information about the Digitalmars-d mailing list