Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Any compiler of sound mind and memory will issue an error

GHC would beg to differ.



Also rustc, though it doesn't quite have overloading in the Java sense: https://is.gd/s0oF79


GHC doesn't either. Rust traits are heavily inspired by Haskell typeclasses… so it's like in your example.


Swift has overloading in the Java sense, and does allow overloading by return type.


That was my first thought, that this is being presented as a fundamental tenant of compilers and really it's a design choice that a whole family of languages, some of them that people even use, didnt make.


Ada also allows return type overloading.

A complaint against Ada is that it is hard for the compiler to figure out the right overloading in a complex statement with many nested function calls. My compilers prof took the time to show how to do it, and why it doesn't take much time.

Too bad C's automatic conversions prevent this from being used in C++.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: