Chapter 9
What predefined data type can be used to conveniently create new singleton types?
The built-in Val type can be used to create new singleton types easily. The Val constructor function can accept any bits-type value and return a singleton of type Val{X}, where X is the value being passed to the constructor function.
What are the benefits of using singleton type dispatch?
Using singleton type dispatch, we can eliminate conditional statements that depend on the data type. It also allows us to add new functionalities by just defining new functions, without having to modify an existing function. Because Julia does the dispatch natively, there is no need to create any custom function just for dispatch.
Why do we want to create stubs?
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access