Java operator overload
        Posted  
        
            by rengolin
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by rengolin
        
        
        
        Published on 2008-09-16T22:04:40Z
        Indexed on 
            2010/03/24
            2:43 UTC
        
        
        Read the original article
        Hit count: 549
        
Coming from C++ to Java, the obvious unanswered question is why not operator overload.
On the web some go about: "it's clearly obfuscated and complicate maintenance" but no one really elaborates that further (I completely disagree, actually).
Other people pointed out that some objects do have an overload (like String operator +) but that is not extended to other objects nor is extensible to the programmer's decision. I've heard that they're considering extending the favour to BigInt and similar, but why not open that for our decisions?
How exactly if complicates maintenance and where on earth does this obfuscate code?
Isn't :
Complex a, b, c; a = b + c;
much simpler than:
Complex a, b, c; a.equals( b.add(c) );
??? Or is it just habit?
© Stack Overflow or respective owner