# \[RFC/WIP\] DuckDispatch.jl

**URL:** https://discourse.julialang.org/t/rfc-wip-duckdispatch-jl/114930
**Category:** Package Announcements
**Tags:** package, multiple-dispatch
**Created:** [May 29, 2024, 5:30pm UTC](https://discourse.julialang.org/t/rfc-wip-duckdispatch-jl/114930 "2024-05-29T17:30:52Z")
**Posts on this page:** 3
**Page:** 2

<div class="post-metadata">

### Author: ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)
#### Post date: [May 31, 2024, 3:11pm UTC](https://discourse.julialang.org/t/rfc-wip-duckdispatch-jl/114930/21 "2024-05-31T15:11:49Z")

</div>

> [@Raf](#):
>
> Also [Interfaces.jl](https://juliahub.com/ui/Packages/General/Interfaces) trait dispatch will entirely compile away

I think I’ve seen mention of trait dispatch in Interfaces.jl in a couple places, but I can’t find it in the documentation. Can you provide an example of what trait dispatch looks like in Interfaces.jl?

---

<div class="post-metadata">

### Author: ![mrufsvold](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mrufsvold/32/31600_2.png) [@mrufsvold](https://discourse.julialang.org/u/mrufsvold)
#### Post date: [May 31, 2024, 4:40pm UTC](https://discourse.julialang.org/t/rfc-wip-duckdispatch-jl/114930/22 "2024-05-31T16:40:31Z")

</div>

A question for the community: When creating a method that dispatches a `DuckType`, the macro produces a generic method to intercept any call that match the number of arguments which does all the wrapping decision making before re-dispatching the wrapped arguments to the same function.

This means, if you try to `@duck_dispatch` a function from another package, you commit type piracy by creating a new method of `f(arg1::Any, ...)`. The macro already checks to see if there is an existing method that would be overwritten, but it doesn’t do anything to make sure that the user owns the function.

Is documenting this behavior sufficient or should a programmatic check be added? If so, how would you even do that?

---

<div class="post-metadata">

### Author: ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)
#### Post date: [May 31, 2024, 5:18pm UTC](https://discourse.julialang.org/t/rfc-wip-duckdispatch-jl/114930/23 "2024-05-31T17:18:40Z")

</div>

There is an `implements` function that returns a `Bool` if a trait is implemented

> **[API reference · Interfaces.jl](https://rafaqz.github.io/Interfaces.jl/stable/api/#Interfaces.implements)**
>
> Documentation for Interfaces.jl.

Or `implemented_trait` if you want to use `Implemented` or `NotImplemented` in dispatch.

[Previous page](https://discourse.julialang.org/t/rfc-wip-duckdispatch-jl/114930.md?page=1)
