What is the partial order used for multiple dispatch?

rveltz
Thu, 28 Aug 2025 13:41:06 +0000
General Usage

In the docs, one can find that a paragraph on multiple dispatch but the dispatching algorithm is not described.

My question is: given two tuples args1, args2 of arguments (or types), what is the partial order < which is used to compare args1, args2 in order to select the “correct” function call (Jeff’s thesis?). I guess, when args1, args2 are uncomparable for <, the algo return a method ambiguity error.

This is a seemingly simple question but it never crossed my mind despite the fact that I use multiple dispatch seemingly ! Could the algo fail to find the “best” method? For example using (+(::Matrix, ::Matrix) instead of +(::Symmetric, ::Symmetric) (very bad example but you get the gist).

6 posts - 3 participants