I try an keep a list of small clear cases where multiple dispatch is a undisputabled better solution
1. Structured Matrix Multiplication.
I have this written up full here, so can read that blog post (or watch the talk version which is at the top of the page)
https://www.oxinabox.net/2020/02/09/whycompositionaljulia.html#are-there-real-world-use-cases-for-multiple-dispatch-
2. Arithmetic Type Promotion
Turns out this is really hard.
A few years ago a large proposal to overhaul Swift’s Integer type was written.
Even in this large document, they explictly:
DOES NOT solve the integer promotion problem, which would allow mixed-type arithmetic. However, we believe that it is an important step in the right direction.
To understand type promotion and why it needs multiple dispatch consider;
+(::Int32, ::Float64)::Float64
+(::Float64, ::Int32)::Float64
+(::Complex{Int32}, ::Float64)::Complex{Float64}
The resulting type depends on both input types, and not in a trivial way either.
3. Contextual Formatting of Objects
IIRC @thautwarm said on twitter something like “The quality of a language can be determined by how hard it is to access polymorpic printing methods”
Which I took to mean this.
This applies to julias whole show(::IO, ::Mime, ::Object)
, but lets sep away from that to think about generating some document.
Lets consider that was have verious objects that need to be displayed:
- Number
- Text
- Equation
And variouis contexts with in the document to display them:
- FlowingContent
- Diagram
- Table
So consider the options:
- Number in general should be shown using proportional figures
- Numbers inside Tables should be shown with tabular figures
- Anything in FlowingContent should be shown in serifed font
- Anything in Diagrams should be shown in with a sanserifed font
- Except Equations in Diagrams should be shown in large sized serifed font