# Brodcasting operator not defined in a macro

**URL:** <https://discourse.julialang.org/t/brodcasting-operator-not-defined-in-a-macro/20587>\
**Category:** General Usage\
**Created:** [February 8, 2019, 4:13pm UTC](https://discourse.julialang.org/t/brodcasting-operator-not-defined-in-a-macro/20587 "2019-02-08T16:13:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [February 8, 2019, 4:13pm UTC](https://discourse.julialang.org/t/brodcasting-operator-not-defined-in-a-macro/20587/1 "2019-02-08T16:13:46Z")

</div>

The broadcasted division (`./`) works as it should in functions:

```julia
function foo()
    [1 2 3] ./ [4 5 6]
end

```

```julia
julia> foo()
1×3 Array{Float64,2}:
 0.25 0.4 0.5

```

… but not in macros:

```julia
macro foo()
    quote
        [1 2 3] ./ [4 5 6]
    end
end

```

```julia
julia> @foo
ERROR: UndefVarError: ./ not defined
Stacktrace:
 [1] top-level scope at REPL[20]:3

```

BTW, the same is true of all basic broadcasted operations that I tested (`.+`, `.-` and `.*`). This problem is relatively easily worked around:

```julia
macro foo2()
    quote
        (/).([1 2 3], [4 5 6])
    end
end

```

```julia
julia> @foo2
1×3 Array{Float64,2}:
 0.25 0.4 0.5

```

but am I missing something? Should I report this as an issue ?

---

<div class="post-metadata">

**Author:** ![bennedich](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bennedich/32/4894_2.png) [@bennedich](https://discourse.julialang.org/u/bennedich)\
**Post date:** [February 8, 2019, 4:34pm UTC](https://discourse.julialang.org/t/brodcasting-operator-not-defined-in-a-macro/20587/2 "2019-02-08T16:34:17Z")

</div>

Another workaround:

```julia
macro foo()
    quote
        @. [1 2 3] / [4 5 6]
    end
end

```

Cf. this issue:  
[https://github.com/JuliaLang/julia/issues/28992](https://github.com/JuliaLang/julia/issues/28992)
