# How to invoke next-most-specific method?

**URL:** <https://discourse.julialang.org/t/how-to-invoke-next-most-specific-method/7664>\
**Category:** General Usage\
**Created:** [December 9, 2017, 9:43pm UTC](https://discourse.julialang.org/t/how-to-invoke-next-most-specific-method/7664 "2017-12-09T21:43:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marius311](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marius311/32/3953_2.png) [@marius311](https://discourse.julialang.org/u/marius311)\
**Post date:** [December 9, 2017, 9:43pm UTC](https://discourse.julialang.org/t/how-to-invoke-next-most-specific-method/7664/1 "2017-12-09T21:43:05Z")

</div>

I was recently super pleasantly surprised to discover the `invoke` method,

> invoke(f, types \<: Tuple, args…)
> 
> Invoke a method for the given generic function matching the specified types, on the specified arguments. The arguments must be compatible with the specified types. This allows invoking a method other than the most specific matching method, which is useful when the behavior of a more general definition is explicitly needed (often as part of the implementation of a more specific method of the same function).

The thing in parentheses is _exactly_ what I want to use `invoke` for. Specifically, I’ve written some custom `broadcast` method, inside of which I want to call the generic `broadcast` that would have been used if my custom one didn’t exist. I could obviously check whatever this generic `broadcast` is now, but I want something that works even if other definitions of `broadcast` are added later.

So is there any programmatic way to figure our what this next-most-specific method would be and to invoke it?

---

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [December 9, 2017, 9:47pm UTC](https://discourse.julialang.org/t/how-to-invoke-next-most-specific-method/7664/2 "2017-12-09T21:47:02Z")

</div>

I don’t think so. See [https://github.com/JuliaLang/julia/pull/13123](https://github.com/JuliaLang/julia/pull/13123) and [https://github.com/JuliaLang/julia/issues/18252](https://github.com/JuliaLang/julia/issues/18252) (edit)

---

<div class="post-metadata">

**Author:** ![marius311](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marius311/32/3953_2.png) [@marius311](https://discourse.julialang.org/u/marius311)\
**Post date:** [December 9, 2017, 10:46pm UTC](https://discourse.julialang.org/t/how-to-invoke-next-most-specific-method/7664/3 "2017-12-09T22:46:41Z")

</div>

Thanks, a ton of useful discussion in there. I left a comment in that first issue as the `call-next-method` mentioned there is exactly what I’m looking for.
