Why isn't global operator overloading allowed in D?

Shriramana Sharma via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Oct 14 08:09:27 PDT 2015


Shriramana Sharma wrote:

> Hello. I just came upon a need in my program to make binary arithmetic
> operators valid between two real[] in my programs, and thought of writing
> a global opOpAssign, but then looked through the documentation, found
> nothing on operator overloading allowed at the global level (even within a
> single module), and searched through the forum and saw this thread:
> http://forum.dlang.org/post/jeyaozvegcnivcppucpo@forum.dlang.org
> 
> Why isn't global operator overloading allowed in D?

Hmm, just now saw this one too: 
http://forum.dlang.org/post/l7nnnb$1ma0$1@digitalmars.com -- posted that too 
hastily.

But really, it's too bad built-in types are different from user-made types 
unlike in Python. In Python, I can inherit from list and dict and whatnot 
(yes I have used them in real apps)...



More information about the Digitalmars-d-learn mailing list