# Macro question

**URL:** <https://discourse.julialang.org/t/macro-question/60348>\
**Category:** New to Julia\
**Tags:** macros\
**Created:** [April 30, 2021, 9:13pm UTC](https://discourse.julialang.org/t/macro-question/60348 "2021-04-30T21:13:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)\
**Post date:** [April 30, 2021, 9:13pm UTC](https://discourse.julialang.org/t/macro-question/60348/1 "2021-04-30T21:13:07Z")

</div>

```julia
module Foo
x = 1
end

@eval Foo begin
    macro m(y) y end
    @m(x)
end
ERROR: LoadError: LoadError: UndefVarError: @m not defined

```

I thought this would define the `@m` macro in the `Foo` module, and then be able to access it. What is happening and how do I fix it?

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [April 30, 2021, 9:55pm UTC](https://discourse.julialang.org/t/macro-question/60348/2 "2021-04-30T21:55:11Z")

</div>

If you just do:

```julia
module Foo
x = 1
end

@eval Foo begin
    macro m(y) y end
end

```

Then it works (`Foo.@m` is defined). And you can:

```julia
julia> @eval Foo begin
           @m x
       end
1

```

I am not entirely sure what the problem is, but maybe it is a time-of-the-world problem.
