int
foo (int, int, double, string)
can this be done in almost paradigms? 🤔 oop, logic, functional, etc.
Funny enough, but no )) N2 and N3 are especially interesting, because those have same number of input parameters. And in order to distinguish them, compiler must be smart enough to differentiate "double" and "bool" types. For example, same javascript doesn't support it because of it's untyped. Same for python. C doesn't support it because it's old, and commitee tends to keep it super simple (which is good). C++ supports it for non-oop code, which I demonstrated with an example, you have to compile it with c++ compiler, but it uses only C features, there are no any oop features used there. In java you can't have non-oop code, so we can cross it out. Scala or groovy are running on jvm, so it's not 100% correct to put them into equation here. Haskell doesn't have direct support for it afaik, only by using another feature for emulating it, but it's better than in javascript. Erlang is a very special language, and overloading is not applicable to it at all. Well, I don't know much about other languages to answer it. But the fact is that I just can't find any example of pure non-oop language that has function overloading feature there directly, without emulation.
Обсуждают сегодня