Hacker News new | ask | show | jobs
by lloeki 5137 days ago
> This is a specific case of the * operator, which is overloaded

It is not operator overloading in the strictest sense, but more of duck typing. In Python (and Ruby), operators are syntactic sugar for method calls on the first operand.

Operator overloading on the contrary suggests a function add(a, b) that reacts differently through polymorphism (i.e according to the types of its arguments).

The distinction is important as overloading and polymorphism simply do not exist in Ruby and Python, only overriding.

1 comments

My hope in using the phrase "operator overloading" was to bring to mind the familiar concept of operator ad-hoc polymorphism (which I would maintain duck typing is an example of) rather than to misleadingly describe the internals of the Python language. Nonetheless you are quite right on the details.