Re:Steve Yegge: Notes from the Mystery Machine Bus
by pheinberg on Friday August 10, 2012 @01:03PM
(#4367073)
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.
[ Parent
| on HN ]
Re:Steve Yegge: Notes from the Mystery Machine Bus
by quatrevingts on Friday August 10, 2012 @09:48PM
(#4369121)
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.
Re:Steve Yegge: Notes from the Mystery Machine Bus
by mark-r on Friday August 10, 2012 @01:59PM
(#4367345)
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.