4 ms·
Because parent is taking about operators like "+" and how it can be confusing not knowing if a function call is behind it. This is different from obvious functi
by thunky 3y ago
Because parent is taking about operators like "+" and how it can be confusing not knowing if a function call is behind it. This is different from obvious functions like "Add()".
- xigoi 3y agoHow is “Add()” any different from “+”? They're just two different names for the same thing – a function that adds two numbers or other objects.
- usrbinbash 3y ago> They're just two different names for the same thing No, they are not. One is a function, the other is an operator. An operator has implicit meaning. I know with absolute certainty, that `+` is supposed to mean that 2 things are added to one another. `Add()` is a function. Its name may or may not indicate what it is actually doing. Even if it indicates it, it may not be obvious how it is doing it's thing, or how good the indication is. Example: If Add takes as first argument a list and as second argument an integer, does it append the integer to the list? Does it add it to every element of the list? Does it sum the list and add the integer to the result? All these things could be meant by "Add"-ing an integer to the list. Does it have side effects? I don't know, and I don't expect to know, until I look at `Add()` (or at least read it's documentation). That is the big difference between operators and functions; With operators, I expect to know what it does, without looking it up. And that's also the big problem with operator-overloading, because as soon as a language supports that, that assumption flies out the window.
- thunky 3y agoBecause if the language doesn't allow overloading (which is the context of this thread) then "+" will always be implemented by the language. That's a big difference.