# \#multiple-dispatch

**URL:** https://discourse.julialang.org/tag/multiple-dispatch/1215.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [Manual control of overloading existing methods](https://discourse.julialang.org/t/manual-control-of-overloading-existing-methods/133836)

<div class="topic-metadata">

**Author:** [@frankwswang](https://discourse.julialang.org/u/frankwswang)\
**Replies:** 19\
**Last updated:** [August 15, 2026, 5:19pm UTC](https://discourse.julialang.org/t/manual-control-of-overloading-existing-methods/133836 "2026-08-15T17:19:25Z")

</div>

I am curious to know how much people want to have a feature/mechanism in Julia to manually control function overloading. Specifically, to disallow overloading already defined methods when intended. One direct motivation…

---

## [World age warning (no @eval) on constructor of different dispatch](https://discourse.julialang.org/t/world-age-warning-no-eval-on-constructor-of-different-dispatch/135947)

<div class="topic-metadata">

**Author:** [@cnaak](https://discourse.julialang.org/u/cnaak)\
**Replies:** 5\
**Last updated:** [March 2, 2026, 2:51pm UTC](https://discourse.julialang.org/t/world-age-warning-no-eval-on-constructor-of-different-dispatch/135947 "2026-03-02T14:51:51Z")

</div>

Updated to julia-1.12 and started a new package. As soon as I defined my first struct with more than one external constructor (nothing fancy, no @evals), I’ve got the world age warning (future error). MWE: struct examp…

---

## [Method ambiguity involving diagonal types](https://discourse.julialang.org/t/method-ambiguity-involving-diagonal-types/133907)

<div class="topic-metadata">

**Author:** [@frankwswang](https://discourse.julialang.org/u/frankwswang)\
**Replies:** 10\
**Last updated:** [November 18, 2025, 8:53am UTC](https://discourse.julialang.org/t/method-ambiguity-involving-diagonal-types/133907 "2025-11-18T08:53:59Z")

</div>

MWE: julia\> f1(argL::T, argR::T) where {T} = 1 f1 (generic function with 1 method) julia\> f1(argL::T1, argR::T2) where {T, T1\<:AbstractArray{T}, T2\<:AbstractArray{T}} = 2 f1 (generic function with 2 methods) julia\> f1…

---

## [What is the partial order used for multiple dispatch?](https://discourse.julialang.org/t/what-is-the-partial-order-used-for-multiple-dispatch/131911)

<div class="topic-metadata">

**Author:** [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Replies:** 5\
**Last updated:** [August 28, 2025, 8:14pm UTC](https://discourse.julialang.org/t/what-is-the-partial-order-used-for-multiple-dispatch/131911 "2025-08-28T20:14:35Z")

</div>

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…

---

## [Avoid writing exponentially many methods for a function that may take vectors or matrices](https://discourse.julialang.org/t/avoid-writing-exponentially-many-methods-for-a-function-that-may-take-vectors-or-matrices/125895)

<div class="topic-metadata">

**Author:** [@JADekker](https://discourse.julialang.org/u/JADekker)\
**Replies:** 3\
**Last updated:** [February 14, 2025, 1:14pm UTC](https://discourse.julialang.org/t/avoid-writing-exponentially-many-methods-for-a-function-that-may-take-vectors-or-matrices/125895 "2025-02-14T13:14:50Z")

</div>

Hi, in my current project I need to compute a function, say f, in N inputs, which all may be either vectors or matrices. In terms of interpretation: a vector is an ‘observation’, and a matrix is a set of observations, wh…

---

## [Ask for advise : Multiple dispatch vs branching performance](https://discourse.julialang.org/t/ask-for-advise-multiple-dispatch-vs-branching-performance/124713)

<div class="topic-metadata">

**Author:** [@Maucejo](https://discourse.julialang.org/u/Maucejo)\
**Replies:** 7\
**Last updated:** [January 14, 2025, 6:26am UTC](https://discourse.julialang.org/t/ask-for-advise-multiple-dispatch-vs-branching-performance/124713 "2025-01-14T06:26:31Z")

</div>

Hi all, I am developing a package for generating structural vibration data, which I hope to release to the community once it is finished. In the course of development, I am faced with a dilemma between multiple dispatch…

---

## [The Unreasonable Efficiency and Effectiveness of Multiple Dispatch: Your Favourite Examples](https://discourse.julialang.org/t/the-unreasonable-efficiency-and-effectiveness-of-multiple-dispatch-your-favourite-examples/119477)

<div class="topic-metadata">

**Author:** [@kapple](https://discourse.julialang.org/u/kapple)\
**Replies:** 36\
**Last updated:** [January 10, 2025, 9:38am UTC](https://discourse.julialang.org/t/the-unreasonable-efficiency-and-effectiveness-of-multiple-dispatch-your-favourite-examples/119477 "2025-01-10T09:38:16Z")

</div>

@Datseris asked if there’s a formally citable reference with the points, examples and concepts presented by @StefanKarpinski on The Unreasonable Effectiveness of Multiple Dispatch. In the slack discussion linked above, …

---

## [Maintainability: Best way to have two versions of the same function with minor differences](https://discourse.julialang.org/t/maintainability-best-way-to-have-two-versions-of-the-same-function-with-minor-differences/122453)

<div class="topic-metadata">

**Author:** [@Tetrakai](https://discourse.julialang.org/u/Tetrakai)\
**Replies:** 5\
**Last updated:** [November 10, 2024, 3:36pm UTC](https://discourse.julialang.org/t/maintainability-best-way-to-have-two-versions-of-the-same-function-with-minor-differences/122453 "2024-11-10T15:36:44Z")

</div>

Say I have two usecases for a function. One logs the result of each iteration and is parallelized using Polyester.@batch, the other only needs to return the final result and uses Threads.@threads. Performance is top prio…

---

## [\[RFC/WIP\] DuckDispatch.jl](https://discourse.julialang.org/t/rfc-wip-duckdispatch-jl/114930)

<div class="topic-metadata">

**Author:** [@mrufsvold](https://discourse.julialang.org/u/mrufsvold)\
**Replies:** 22\
**Last updated:** [May 31, 2024, 5:18pm UTC](https://discourse.julialang.org/t/rfc-wip-duckdispatch-jl/114930 "2024-05-31T17:18:40Z")

</div>

I’ve been working through an idea for a package, and I’d love your feedback. Tl;Dr: This package allows you to create method dispatches based on the methods defined for a type, not the place the type has in the type l…

---

## [Discontiguous Lexical Scope for Multiply Dispatched Functions](https://discourse.julialang.org/t/discontiguous-lexical-scope-for-multiply-dispatched-functions/114972)

<div class="topic-metadata">

**Author:** [@blabatt](https://discourse.julialang.org/u/blabatt)\
**Replies:** 9\
**Last updated:** [May 31, 2024, 3:31pm UTC](https://discourse.julialang.org/t/discontiguous-lexical-scope-for-multiply-dispatched-functions/114972 "2024-05-31T15:31:51Z")

</div>

I would like to create a closure that binds free variables with respect to a discontiguous “lexical environment” that encapsulates both the disparate method implementations and collective reference to a multiply-dispatch…

---

## [Technical term for "operator inference" related to multiple dispatch](https://discourse.julialang.org/t/technical-term-for-operator-inference-related-to-multiple-dispatch/114109)

<div class="topic-metadata">

**Author:** [@younes](https://discourse.julialang.org/u/younes)\
**Replies:** 5\
**Last updated:** [May 10, 2024, 5:19pm UTC](https://discourse.julialang.org/t/technical-term-for-operator-inference-related-to-multiple-dispatch/114109 "2024-05-10T17:19:45Z")

</div>

I have defined the operator \< for my custom type Person: begin struct Person name::String age::Int end import Base: \< function \<(a::Person, b::Person)::Bool return a.age \< b.age end # Example …

---

## [Possible to know if a certain method supports a certain keyword?](https://discourse.julialang.org/t/possible-to-know-if-a-certain-method-supports-a-certain-keyword/112498)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 4\
**Last updated:** [April 4, 2024, 8:22am UTC](https://discourse.julialang.org/t/possible-to-know-if-a-certain-method-supports-a-certain-keyword/112498 "2024-04-04T08:22:18Z")

</div>

Is it possible to know if a certain method supports a certain keyword argument, or one has to use exceptions?

---

## [This function seems to allocate memory only if the argument types are not annotated in the definition](https://discourse.julialang.org/t/this-function-seems-to-allocate-memory-only-if-the-argument-types-are-not-annotated-in-the-definition/110193)

<div class="topic-metadata">

**Author:** [@Joaquin\_Rodriguez](https://discourse.julialang.org/u/Joaquin_Rodriguez)\
**Replies:** 5\
**Last updated:** [February 14, 2024, 1:41pm UTC](https://discourse.julialang.org/t/this-function-seems-to-allocate-memory-only-if-the-argument-types-are-not-annotated-in-the-definition/110193 "2024-02-14T13:41:17Z")

</div>

I am defining a custom data type that behaves like a vector (in the linear algebra sense). I defined it as a structure with a 6-element StaticVector that holds the underlying data: using StaticArrays struct MyVectorTyp…

---

## [Tutorials/books on C++ Object Oriented methodology to Julia Multiple Dispatch](https://discourse.julialang.org/t/tutorials-books-on-c-object-oriented-methodology-to-julia-multiple-dispatch/107289)

<div class="topic-metadata">

**Author:** [@PatrickChampion.NCHS](https://discourse.julialang.org/u/PatrickChampion.NCHS)\
**Replies:** 13\
**Last updated:** [December 11, 2023, 3:23pm UTC](https://discourse.julialang.org/t/tutorials-books-on-c-object-oriented-methodology-to-julia-multiple-dispatch/107289 "2023-12-11T15:23:03Z")

</div>

Can someone give like the 5 best Tutorials, whitepapers, or books that clearly describe how to map classic C++ (or Java) object orientation (inheritance, virtual constructor/destructors, polymorphism, and templates) into…

---

## [Parametric types & multiple dispatch](https://discourse.julialang.org/t/parametric-types-multiple-dispatch/106650)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 7\
**Last updated:** [November 27, 2023, 9:30am UTC](https://discourse.julialang.org/t/parametric-types-multiple-dispatch/106650 "2023-11-27T09:30:34Z")

</div>

Method choice can be determined by a parametric type struct X{x} end f(::X{:x1}) = 1 f(::X{:x2}) = 2 f(X{:x1}()) # 1 f(X{:x2}()) # 2 Why not allow it to be determined just with the parameter ? f({:x1}) = 1 f({:x2}) …

---

## [Multiple dispatch on function types](https://discourse.julialang.org/t/multiple-dispatch-on-function-types/101932)

<div class="topic-metadata">

**Author:** [@aberges](https://discourse.julialang.org/u/aberges)\
**Replies:** 16\
**Last updated:** [August 17, 2023, 9:07am UTC](https://discourse.julialang.org/t/multiple-dispatch-on-function-types/101932 "2023-08-17T09:07:40Z")

</div>

I’m designing a small module to compute fractals. I have implemented 2 algorithms: escape time and distance estimation. These algorithms have the exact same arguments except that distance estimation needs 1 more. On the…

---

## [InlineDispatch.jl – A simple module to perform dispatch on the value of an expression](https://discourse.julialang.org/t/inlinedispatch-jl-a-simple-module-to-perform-dispatch-on-the-value-of-an-expression/102780)

<div class="topic-metadata">

**Author:** [@HanD](https://discourse.julialang.org/u/HanD)\
**Replies:** 0\
**Last updated:** [August 14, 2023, 6:41am UTC](https://discourse.julialang.org/t/inlinedispatch-jl-a-simple-module-to-perform-dispatch-on-the-value-of-an-expression/102780 "2023-08-14T06:41:08Z")

</div>

Based on a discussion here on Discourse, I’m happy to announce a new package called InlineDispatch.jl for dispatching on values using anonymous functions. The following expression: @dispatch expr begin v::T…

---

## [\[Design pattern\] How to let my package internally use functions of another package it does know nothing about?](https://discourse.julialang.org/t/design-pattern-how-to-let-my-package-internally-use-functions-of-another-package-it-does-know-nothing-about/102149)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 10\
**Last updated:** [July 27, 2023, 8:02pm UTC](https://discourse.julialang.org/t/design-pattern-how-to-let-my-package-internally-use-functions-of-another-package-it-does-know-nothing-about/102149 "2023-07-27T20:02:56Z")

</div>

Hello, my objective is to have an imputer in my Machine Learning package that internally could use as actual imputer for each dimension (column) of the provided matrix any estimator that provides the “interface” mod=Mode…

---

## [If Julia was static typed, how multiple dispatch would work?](https://discourse.julialang.org/t/if-julia-was-static-typed-how-multiple-dispatch-would-work/95529)

<div class="topic-metadata">

**Author:** [@dylanxyz](https://discourse.julialang.org/u/dylanxyz)\
**Replies:** 3\
**Last updated:** [March 5, 2023, 1:52am UTC](https://discourse.julialang.org/t/if-julia-was-static-typed-how-multiple-dispatch-would-work/95529 "2023-03-05T01:52:03Z")

</div>

If Julia was a static typed language instead of dynamic typed, how would multiple dispatch work? It would be simple function overloading or something different? Instead of compiling the functions that are called during r…

---

## [Type() vs type() -- Are constructor methods or conversion functions more idiomatic?](https://discourse.julialang.org/t/type-vs-type-are-constructor-methods-or-conversion-functions-more-idiomatic/93233)

<div class="topic-metadata">

**Author:** [@SortofDamocles](https://discourse.julialang.org/u/SortofDamocles)\
**Replies:** 4\
**Last updated:** [January 20, 2023, 10:17am UTC](https://discourse.julialang.org/t/type-vs-type-are-constructor-methods-or-conversion-functions-more-idiomatic/93233 "2023-01-20T10:17:55Z")

</div>

I am writing some code with structs that represent dual forms of the same underlying thing, e.g. struct NormalForm normal\_data descriptive\_parameter end NormalForm(data) = NormalForm(data, process(data)) struct…

---

## [Implementing broadcasting for a nested \`Vector\` with a scalar](https://discourse.julialang.org/t/implementing-broadcasting-for-a-nested-vector-with-a-scalar/92760)

<div class="topic-metadata">

**Author:** [@loonatick-src](https://discourse.julialang.org/u/loonatick-src)\
**Replies:** 7\
**Last updated:** [January 11, 2023, 6:36am UTC](https://discourse.julialang.org/t/implementing-broadcasting-for-a-nested-vector-with-a-scalar/92760 "2023-01-11T06:36:50Z")

</div>

Say I have a struct one of whose members has the type RaggedVector{T} = Vector{Vector{T}} And if we construct two conformal instances of this type xs = \[\[1, 2, 3\], \[4\], \[5, 6\]\] ys = \[\[6, 5, 4\], \[3\], …

---

## [Why can't I use Vector{Int64} with functions expecting Vector{Integer}?](https://discourse.julialang.org/t/why-cant-i-use-vector-int64-with-functions-expecting-vector-integer/91779)

<div class="topic-metadata">

**Author:** [@Titas22](https://discourse.julialang.org/u/Titas22)\
**Replies:** 4\
**Last updated:** [December 17, 2022, 5:59pm UTC](https://discourse.julialang.org/t/why-cant-i-use-vector-int64-with-functions-expecting-vector-integer/91779 "2022-12-17T17:59:47Z")

</div>

Hi, I was trying to define a function that would work on all integer types, and could not get it to work when the input is matrix or vector. functions taking in single value of Int64 or Integer work fine. But if I call…

---

## [Wield behavior of multiple dispatch](https://discourse.julialang.org/t/wield-behavior-of-multiple-dispatch/90986)

<div class="topic-metadata">

**Author:** [@1115](https://discourse.julialang.org/u/1115)\
**Replies:** 6\
**Last updated:** [November 29, 2022, 3:24pm UTC](https://discourse.julialang.org/t/wield-behavior-of-multiple-dispatch/90986 "2022-11-29T15:24:20Z")

</div>

In Julia 1.8.3. Given the following two type signatures. (x::AbstractFloat, y::Number) (x::Union{Float64, ComplexF64}, y::Union{Float64, ComplexF64}) I would expect there being an ambiguity error if the input type is (…
