Summary

In this chapter, we learned about various topics related to subtyping, variance, and dispatch. These concepts are the fundamental building blocks for creating larger, more complex applications.

We first went over the topic of implementation inheritance and behavior subtyping and the differences between them. We reasoned that implementation inheritance is not a great design pattern because of various issues. We came to an understanding that Julia's type system is designed to avoid the flaws that we have seen in other programming languages.

Then, we reviewed different kinds of variance, which are nothing but ways to explain the subtyping relationship between parametric types. We walked through in great details how parametric types are invariant and method arguments are covariant. We then went even further to discuss the variance of function types and how we can build our own data type that wraps a function for dispatch purpose.

Finally, we revisited parametric methods and looked at how type variables are specified and matched during dispatch. We learned about the diagonal rule, which is a key design feature in the Julia language that allows us to enforce type consistency across method arguments in an intuitive manner.

We are now finished with the chapter and the book. Thank you for reading it!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.97.157