Thread: Programming!
View Single Post
  #63    
Old March 3rd, 2013, 11:11 AM
Archenoth's Avatar
Archenoth
The arch foe
 
Join Date: Jan 2012
Gender: Male
Nature: Lonely
Quote:
Originally Posted by twocows View Post
Your examples seem more like misleading spacing than anything. The problem I have with operator overloading is that it introduces ambiguity with regards to a given operator. You have to look at the context to figure out what it does, and that's just stupid. What an operator does should be self-evident; it should mean the same thing in every context. Overloading string concatenation is fine I guess because it doesn't do this; you're still essentially "adding" two things, even if internally it's completely different. But a lot of times this isn't what happens; operators are overloaded to mean all sorts of stuff that isn't even remotely related. This is horrible. And letting the programmer do it at his leisure is even worse; at least in C you can guarantee that * is going to mean one of three things and not fifteen other things that the programmer might have defined somewhere.
Misleading spacing was indeed part of it. My point was that you can write code in obvious, and non-obvious ways. The same is true for code that utilizes overloaded operators.

Your code should be consistent and readable. Establish a way you use overloaded operators so that you don't really need context when looking at a given function; Make things obvious.

I won't quote your entire post, but you described your thoughts quite well and had some good points (Even if you were a bit condescending.). While I still don't share your opinion, I understand it better... So have a like.

Last edited by Archenoth; March 3rd, 2013 at 11:41 AM.
Reply With Quote