Hacker News new | past | comments | ask | show | jobs | submit login

I don't think the main problem with operator overloading is "abuse"; I think it's that there's absolutely no way to know what a given clause of code might mean, even if the overloading has been defined by excellent coders.

It's pretty obvious what it means: + means call the + function. Well what does that mean? Probably something additive. Just like if it were called "add". You don't really know in either case unless you read the function.

The risk is that programmers might start using symbols in a way that is not obvious, but what is obvious is highly contextual. I'd prefer it not be the language designer who decides which operators are obvious enough to be allowed in my context.

I think it has more to do with expected outcomes. It's hard to argue that a + operator on a string or matrix class is a bad idea, because the outcome is intuitively obvious. For the other extreme see boost spirit for C++, which I'm sure was written by excellent coders.

Actually, it's not at all obvious what a + operator on a string does. Some languages think it means string concatenation. Others think it means convert the strings to numbers and add them.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact