4 ms·
I agree that operator overloading should be restricted to math objects. D tries to make it unpleasant to do it for non-math objects. For example, < <= > >= are
by WalterBright 6y ago
I agree that operator overloading should be restricted to math objects. D tries to make it unpleasant to do it for non-math objects. For example, < <= > >= are not overloadable separately, just one function `opCmp` does all of them. Non-math operators are not overloadable.
The D community has generally agreed, and we haven't had much trouble with people overloading operators to do a regular expression DSL, for example.
- meltedcapacitor 6y agoFair enough, but mainstream languages used in broad commercial settings need moron-immunity more than niche languages attracting a select crowd.
- WalterBright 6y agoD does not have a huge market presence, but it is not a niche language. It is very capable for a diverse variety of projects. Whenever you get tired of buffer overflows and preprocessor abuse, come check us out :-)
- pjmlp 6y agoWe still need @safe as default though.
- WalterBright 6y agoThe buffer overflow protection is so important it is there whether the code is marked @safe or not.
- pjmlp 6y agoWith @system by default it is harder to track down uses of .ptr