3 ms·
Smalltalk also doesn't have this problem. Since all message-sends are essentially infix, operators (binary message sends) are simply special keyword messages.
by mpweiher 8y ago
Smalltalk also doesn't have this problem. Since all message-sends are essentially infix, operators (binary message sends) are simply special keyword messages.
1 add: 2.
1 + 2.
This is helpful when you have "operators" that aren't quite as obvious, for example raising to a power.
2 raisedTo:3.
Since there are no operators, there is no operator precedence. However, there is precedence between different message types: unary binds tightest, then binary, keyword last. Otherwise evaluation is uniformly left to right.
While this is a question on Smalltalk job interviews ( What is 2 + 3 * 5. ?), that's only useful for filtering out people who simply have never seen Smalltalk before (in case they claim knowledge). It doesn't seem to be an issue in practice, because the evaluation rules are otherwise so simple and uniform.
The other surprising effect is that binary message sends don't seem to have the same tendency to be confusing that operator overloading does. I don't really understand this effect, because the mechanism has effectively the same power.