# Why isn't julia broadcasting through my function

**URL:** <https://discourse.julialang.org/t/why-isnt-julia-broadcasting-through-my-function/135959>\
**Category:** Performance\
**Created:** [March 2, 2026, 4:35pm UTC](https://discourse.julialang.org/t/why-isnt-julia-broadcasting-through-my-function/135959 "2026-03-02T16:35:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![atteson](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@atteson](https://discourse.julialang.org/u/atteson)\
**Post date:** [March 2, 2026, 4:35pm UTC](https://discourse.julialang.org/t/why-isnt-julia-broadcasting-through-my-function/135959/1 "2026-03-02T16:35:54Z")

</div>

Why isn’t julia broadcasting through the function `f2` below:

```julia-auto
f1(x) = "scalar"
Base.broadcasted( ::typeof(f1), x ) = "broadcasted"

x = randn(10);

f1.(x)

f2(x) = f1(x)
f2.(x)

```

I would like `f2.(x)` to return `"broadcasted"`. It seems to do this at least for operators.

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [March 2, 2026, 4:40pm UTC](https://discourse.julialang.org/t/why-isnt-julia-broadcasting-through-my-function/135959/2 "2026-03-02T16:40:28Z")

</div>

Broadcast just doesn’t work that way. It doesn’t recurse down through the inner layers of your function definitions. The broadcast machinery has no idea that you customized `f1` when you passed it a totally different function `f2`.

```julia-auto
julia> f1 === f2
false

```

Did you mean to isntead make an alias of `f1`? i.e. something like

```julia-auto
julia> f3 === f1
true

julia> f3.(x)
"broadcasted"

```

---

<div class="post-metadata">

**Author:** ![atteson](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@atteson](https://discourse.julialang.org/u/atteson)\
**Post date:** [March 2, 2026, 4:43pm UTC](https://discourse.julialang.org/t/why-isnt-julia-broadcasting-through-my-function/135959/3 "2026-03-02T16:43:13Z")

</div>

OK. Thank you. I thought it did.

---

<div class="post-metadata">

**Author:** ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)\
**Post date:** [March 2, 2026, 4:45pm UTC](https://discourse.julialang.org/t/why-isnt-julia-broadcasting-through-my-function/135959/4 "2026-03-02T16:45:44Z")

</div>

Yeah I can see how this might be confusing.

When you write `f2(x) = ...` that creates a whole new function `f2`.

Your function just happens to have a very simple implementation which just calls `f1`, but as far as the broadcast machinery, the type system, and everything are concerned, it’s a totally distinct object.
