Well, m is not a global because of the let blog. Because you evaluate that 
statement, m needs to be in the scope of the macro, which it is only for 
msg (msg is global).
You probably don't want to eval in a macro, and just return an expression 
instead. That's what macros do, take an expression and replace that 
expression at compile time.
e.g.
macro example(var)
    :(dump($var))
end

So this:
let m = "hola"
       @example m
       end
will be expanded at compile time to:
let m = "hola"
   dump(m)
end
so they're in the same scope now.
You might find macroexpand useful: macroexpand(:( @mymacro my_expr)))

Am Samstag, 12. September 2015 23:45:23 UTC+2 schrieb Diego Javier Zea:
>
> I don't understand why am I getting this error? My macros can not find the 
> variables inside *let* blocks. How Can I fix it? Thanks in advance
>
> julia> macro example(var)
>        dump(var)
>        @eval dump($var)
>        end
>
> julia> msg = "hola"
> "hola"
>
> julia> @example msg
> Symbol msg
> ASCIIString "hola"
>
> julia> let m = "hola"
>        @example m
>        end
> Symbol m
> ERROR: UndefVarError: m not defined
>  in eval_user_input at REPL.jl:64
>  [inlined code] from REPL.jl:93
>  in anonymous at task.jl:68
>
>
>
>
>

Reply via email to