Thoughts

mental health break ,./'"**^^$_---
Function overloading enables three patterns.
First, a default behavior that is customizable. For example, `parseInt` could be implemented to take a string-number and a base, but calling it with just a string-number, could call the other implementation with the string-number and 10. Second, a trivial base case, and a general case. This is what we see frequently in Haskell, where the general case is recursive. The ability to split a problem into a base-case and a general-case is really powerful, and I like that Haskell allows that split to carry into function definitions. This basically requires pattern-matching, not just function overloading on types. Third, Julia-style overloading on multiple types. This is different from the other two examples here in that the different function declarations have totally independent implementations. I can have an "add" function that does one thing with vectors and another thing with matrices, and the only reason they're the same function is because they're the same function in English. The code for adding a vector isn't necessarily similar to the code for adding a matrix.
Link 2:17 p.m. Jun 07, 2023 UTC-7