This is a question regarding how Multiple Dispatch works. Suppose that we have a type hierarchy like this:Drawable -> Shape -> Polygon -> RectangleAnd there are three functions (This is a pseudo-code):void func(Rectangle*, Drawable*, Drawable*) ...void func(Rectangle*, Rectangle*, Drawable*) ...void func(Polygon*, Rectangle*, Rectangle*) ...And suppose that this is a piece of code:Drawable* x = create_rectangle();Drawable* y = create_rectangle();Drawable* z = create_rectangle();Obviously types of x,y,z are all Drawable but they contain instances of a Rectangle. Which function will be called if I write: func(x, y, z)?We don't have any function which matches exact types of x, y and z so what happens in this case?
Strategy for implementing Multiple Dispatch
programming languages;functional programming;methods;multiple dispatch
You can implement this several ways.  The way that would be least surprising to me is to prefer the least abstract match and to look for it from left to right.In this case that means you'd call:void func(Rectangle*, Rectangle*, Drawable*) ...