|
|
|
|
|
by patio11
6057 days ago
|
|
I think the point is even better than a joke: there is a danger in allowing things like, e.g., operator overloading (or redefining methods in the standard library), because programmers have different feelings about what the code "obviously" means. If in your language, + means string concatenation by convention, then + darn well means string concatenation. If in your language + means "contextually appropriate depending on what arguments you pass to it", then "abc" + "def" => "egi" doesn't strike me as obviously wrong. More broadly, consider a language in which we teach initiates that "Plus adds things in the way you'd expect!" map = {} map2 = map + {"key" => "contents"} What are the contents of map and map2 now? Uh oh. More worrisome: map = MemcachedWrapper.new map2 = map + {"key" => "contents"} What just happened? |
|
Avoiding operator overload doesn't avoid poorly named methods, nor does it avoid the need for documentation. All that it does is force programmers to do ugly things when dealing with math, and there is a lot of math-based programming out there.