Playing with the animals in the countryside
This chapter covers
- Mimicking objects with multimethods (single dispatch)
- Implementing multimethod on several argument types (multiple dispatch)
- Implementing multimethods dynamically on several arguments (dynamic dispatch)
OOP is well-known for allowing different classes to be called with the same interface via a mechanism called polymorphism. It may seem that the only way to have polymorphism in a program is with objects. In fact, in this chapter, we are going to see that it is possible to have polymorphism without objects, thanks to multimethods. Moreover, multimethods provide a more advanced polymorphism than OOP polymorphism because they support cases where the chosen implementation ...