# Do syntax for macro invocations no longer works (v0.7)

**URL:** <https://discourse.julialang.org/t/do-syntax-for-macro-invocations-no-longer-works-v0-7/11792>\
**Category:** General Usage\
**Created:** [June 19, 2018, 7:27pm UTC](https://discourse.julialang.org/t/do-syntax-for-macro-invocations-no-longer-works-v0-7/11792 "2018-06-19T19:27:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![essenciary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/essenciary/32/210469_2.png) [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Post date:** [June 19, 2018, 7:27pm UTC](https://discourse.julialang.org/t/do-syntax-for-macro-invocations-no-longer-works-v0-7/11792/1 "2018-06-19T19:27:16Z")

</div>

I have this macro definition:

```julia
julia> macro foreach(f, arr)
         quote
           isempty($arr) && return ""
           mapreduce(*, $arr) do _s
             $f(_s)
           end
         end
       end
@foreach (macro with 1 method)

```

In Julia v0.6 this works:

```julia
julia> @foreach(["a", "b", "c"]) do (x)
             x
       end
"abc"

```

In Julia v0.7 it doesn’t:

```julia
julia> @foreach(["a", "b", "c"]) do (x)
             x
       end
ERROR: syntax: invalid macro usage "@(foreach(["a", "b", "c"]) do x
    # REPL[11], line 2
    x
end)"

```

Why not and how to get it back? 😟

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [June 19, 2018, 8:18pm UTC](https://discourse.julialang.org/t/do-syntax-for-macro-invocations-no-longer-works-v0-7/11792/2 "2018-06-19T20:18:35Z")

</div>

It works for me in 0.7.0-alpha.197

(Why are you writing a macro and not a function here, or for that matter using the built-in `foreach` function?)

Related: [https://github.com/JuliaLang/julia/issues/15730](https://github.com/JuliaLang/julia/issues/15730)

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [June 19, 2018, 8:35pm UTC](https://discourse.julialang.org/t/do-syntax-for-macro-invocations-no-longer-works-v0-7/11792/3 "2018-06-19T20:35:02Z")

</div>

Likely fixed by [https://github.com/JuliaLang/julia/pull/27538](https://github.com/JuliaLang/julia/pull/27538)

---

<div class="post-metadata">

**Author:** ![essenciary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/essenciary/32/210469_2.png) [@essenciary](https://discourse.julialang.org/u/essenciary)\
**Post date:** [June 19, 2018, 8:46pm UTC](https://discourse.julialang.org/t/do-syntax-for-macro-invocations-no-longer-works-v0-7/11792/4 "2018-06-19T20:46:29Z")

</div>

@kristoffer.carlsson Awesome, thank you very much. I’m on 0.7.0-alpha.0 – I’ll update my Julia.

@stevengj it’s a helper which needs to do exactly that, a `mapreduce` over `*`. A real-life example is

```julia
@foreach(tweets) do tweet
  include_template("app/resources/tweets/views/partials/tweet.flax.html")
end

```

I think I ended up with the macro a while ago, most likely because `Base.foreach` already existed and the functions would have had the same signature. I’ve added a `foreachstr` function now but it’s an uglier name.
