# Broadcast and .\* not the same

**URL:** <https://discourse.julialang.org/t/broadcast-and-not-the-same/7935>\
**Category:** General Usage\
**Created:** [December 23, 2017, 12:43am UTC](https://discourse.julialang.org/t/broadcast-and-not-the-same/7935 "2017-12-23T00:43:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![srwhite59](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/srwhite59/32/2992_2.png) [@srwhite59](https://discourse.julialang.org/u/srwhite59)\
**Post date:** [December 23, 2017, 12:43am UTC](https://discourse.julialang.org/t/broadcast-and-not-the-same/7935/1 "2017-12-23T00:43:31Z")

</div>

I have an AutoVector type for which broadcast(_,v,v) works but v ._ v doesn’t. The indexing is  
more flexible than the usual type, so I don’t want it to be a subtype of AbstractVector. Here is  
a drastically simplified set of code that illustrates the problem:

```julia
mutable struct AutoVector  
    dat::Vector{Float64}
end

import Base.broadcast
function broadcast(::typeof(*),x::AutoVector,y::AutoVector)
    println("got here")
end

av = AutoVector([1.0])

println("Calling broadcast")
broadcast(*,av,av)

println("Calling .*")
av .* av

```

================================  
This is julia 0.6.2  
julia AV2.jl

```julia
Calling broadcast
got here
Calling .*
ERROR: LoadError: MethodError: no method matching *(::AutoVector, ::AutoVector)
Closest candidates are:
  *(::Any, ::Any, !Matched::Any, !Matched::Any...) at operators.jl:424
Stacktrace:
 [1] (::##1#2)(::AutoVector) at ./<missing>:0
 [2] broadcast(::Function, ::AutoVector) at ./broadcast.jl:455
 [3] include_from_node1(::String) at ./loading.jl:576
 [4] include(::String) at ./sysimg.jl:14
 [5] process_options(::Base.JLOptions) at ./client.jl:305
 [6] _start() at ./client.jl:371
while loading /Users/srw/Dropbox/julia/Modules/AV2.jl, in expression starting on line 16

```

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [December 23, 2017, 2:16am UTC](https://discourse.julialang.org/t/broadcast-and-not-the-same/7935/2 "2017-12-23T02:16:40Z")

</div>

Yes, dot fusion creates an anonymous function to broadcast over. Don’t define `broadcast` calls on specific functions.

---

<div class="post-metadata">

**Author:** ![tkoolen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkoolen/32/1603_2.png) [@tkoolen](https://discourse.julialang.org/u/tkoolen)\
**Post date:** [December 23, 2017, 3:56am UTC](https://discourse.julialang.org/t/broadcast-and-not-the-same/7935/3 "2017-12-23T03:56:02Z")

</div>

For 0.6, see [Broadcast for custom type - #3 by fengyang.wang](https://discourse.julialang.org/t/broadcast-for-custom-type/3497/3) for how to implement broadcast for a custom type. Note that a lot changes to `broadcast[!]` are coming in 0.7/1.0:

- [https://github.com/JuliaLang/julia/pull/23939](https://github.com/JuliaLang/julia/pull/23939) (improve ability to extend `broadcast` and properly document the process)
- [https://github.com/JuliaLang/julia/pull/24992](https://github.com/JuliaLang/julia/pull/24992) (improve ability to extend `broadcast!` and avoid ambiguities between packages in similar fashion)
- [https://github.com/JuliaLang/julia/pull/23692](https://github.com/JuliaLang/julia/pull/23692)
