Why can't we derive struct's?

Walter Bright newshound2 at digitalmars.com
Tue Dec 25 11:31:17 UTC 2018


On 12/24/2018 6:43 PM, Rubn wrote:
> You can easily make the "+" operator do something entirely different than 
> addition.
If you want to make "+" non-commutative, you have to work a little harder.

I'm happy to see that D has successfully inculcated a culture that attempting to 
use operator overloading for non-arithmetic purposes is a code smell, rather 
than celebrating it as C++ does. It's like:

#define BEGIN {
#define END }

is considered a smell in C (it didn't use to be, it took a while to stamp that out).

We'll not be accepting such practices into the D standard library, etc., and 
will do what we can to discourage such.

So yes, if you try hard enough, you can write execrable code. But you'll be on 
your own with it.


More information about the Digitalmars-d mailing list