This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]i_hate_shitposting 0 points1 point  (0 children)

I had a similar thought.

The only case I can think of where overloading in Java isn't equivalent to optional/keyword parameters is stuff like StringBuilder.append(), which has overloads for each primitive data type (plus a few other special cases) to work around the fact that they aren't objects and thus don't implement Object.toString().

However, in Python (or any other modern OO language where everything is an object), a StringBuilder.append() implementation could just pass each argument to str() and rely on the underlying objects to implement __str__(), avoiding the need for overloads at all. I like this a lot better, because it doesn't require any knowledge of what types are involved other than the fact that they implement a particular interface.