# Help with for loop in a macro with varargs

**URL:** <https://discourse.julialang.org/t/help-with-for-loop-in-a-macro-with-varargs/15564>\
**Category:** New to Julia\
**Tags:** metaprogramming\
**Created:** [September 27, 2018, 3:10pm UTC](https://discourse.julialang.org/t/help-with-for-loop-in-a-macro-with-varargs/15564 "2018-09-27T15:10:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kaiyin\_Zhong](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kaiyin_zhong/32/1956_2.png) [@Kaiyin\_Zhong](https://discourse.julialang.org/u/Kaiyin_Zhong)\
**Post date:** [September 27, 2018, 3:10pm UTC](https://discourse.julialang.org/t/help-with-for-loop-in-a-macro-with-varargs/15564/1 "2018-09-27T15:10:30Z")

</div>

I have the following code:

```julia
module Heroku
using HTTP
herokuHost = HTTP.URI("https://api.heroku.com/")
addPath(uri::HTTP.URI, path::AbstractString) = merge(herokuHost, path=joinpath(herokuHost.path, path))
# apps = Heroku.addPath(Heroku.herokuHost, "apps")
macro genuri(p::Symbol)
    return quote
        global $p
        $p = Heroku.addPath(Heroku.herokuHost, $(string(p)))
    end
end
@genuri account
macro genuris(ps::Symbol...)
    return quote
        for p = $ps
            global $p
            $p = Heroku.addPath(Heroku.herokuHost, $(string(p)))
        end
    end
end
@genuris apps news
end
Heroku.account

```

The macro `genuri` that deals with a single arg works fine, although I’m not sure whether I should have used `$(esc(p))` instead of `$p` in the assignment.

The varargs macro `genuris` fails with the error `LoadError: UndefVarError: p not defined`.

How can I solve this?
