Hacker News new | ask | show | jobs
by isidor3 1898 days ago
The most "complicated" part about operator overloading (in my opinion) is dealing with precedence rules. Some languages, instead of dealing with this complexity, treat all operators the same. Lisp-like languages, for instance, by way of how the programs are structured, doesn't need rules for precedence. APL/J just does away with any idea of precedence and instead each operator acts on the result of the expression to its right. This breaks common arithmetic rules (2 * 2 + 2 evaluates to 8, for example), but I wonder if a language otherwise like C/C#/Java ditched precedence and allowed custom and overridable operators, if the result would be a lot less complex overall than some of the messes that can be found in C++.