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:01:57 PDT 2015


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?

Having to construct a class just to write a quick operator overload for two 
built-in types isn't a clean solution, so please don't suggest that (like it 
was suggested in the other thread).

Thanks.

Shriramana Sharma.



More information about the Digitalmars-d-learn mailing list