4 Comments

That's actually a very pratical low-level concept. Thanks a lot!

Expand full comment

Aren't there other more pythonic ways such as duck typing or protocols to approach these problems, rather than doing something "like it's done in C++"?

Expand full comment

Duck typing is great, no doubt, and it also offers that polymorphic touch to your code.

But the only problem I see here is that you cannot constrain the function's utility to specific data types, unless you explicitly define those constraints using conditionals. Another issue is that you cannot have multiple definitions with different parameters like I talked above. Of course, *args and **kwargs offers this but then no one can find out what's going inside that function, so I have seldom been a fan of this.

Using @dispatch might not be perfect for all cases, I agree. But for my particular case, I found it to be better than relying on duck typing and having those multiple definitions for polymorphic code.

Expand full comment

This is a crap article. First, function overloading is NOT a defining feature of OOP. It is a defining feature of C++ and Jave, neither of which is an example of an OOP language. They are based on Simula, an ADT based language. OO languages descend or are inspired from Smalltalk, the original OOP language as its creator coined the term.

Python is more OO than either C++ or Java.

Finally, function overloading is a controversial topic and more often than not leads to unexpected programming errors.

Expand full comment