Julia supports dynamic dispatch, which is a specific feature of its multiple dispatch system. Dynamic dispatch allows the program to dispatch to the proper function based on the type of the function arguments at runtime. If you are familiar with polymorphism in terms of object-oriented programming languages, then this concept is similar. In this section, we will explain what singleton types are and how they can be used to implement dynamic dispatch.
To begin, let's consider a desktop application use case where the system responds to user click events. Here is what the graphical user interface (GUI) may look like:
We will try to implement the processing function with simple logic first and then see how it can be improved using the singleton type dispatch pattern.