Ad hoc polymorphism

This differs from parametric polymorphism, in which the function would need to be written generically, to work with any kind of list.

This can be seen as advantage (more descriptive) or a disadvantage (overly verbose) depending on one's point of view.

An advantage that is sometimes gained from overloading is the appearance of specialization, e.g., a function with the same name can be implemented in multiple different ways, each optimized for the particular data types that it operates on.

This can provide a convenient interface for code that needs to be specialized to multiple situations for performance reasons.

Since overloading is done at compile time, it is not a substitute for late binding as found in subtyping polymorphism.

The previous section notwithstanding, there are other ways in which ad hoc polymorphism can work out.

A closer look will also reveal that Smalltalk provides a slightly different variety of ad hoc polymorphism.