November 2019
Intermediate to advanced
56 pages
37m
English
I would like to examine the theme of polymorphism. Polymorphism is a property of a function. When a function is polymorphic, its behavior will depend on the arguments you give to it. The most common type of polymorphism is type-based. In a language like Java, you call methods on objects. The object on which you call a method is an implicit first argument to the method, and the code that runs will depend on the type of that object.
The decision about which code to run is called dispatch. Aside from type-based dispatch on the first argument, dispatch could also consider the number of arguments, the type of each of the arguments, and so on.
Clojure gives you a few options for polymorphic dispatch:
Read now
Unlock full access