# Problem evaluating symbol for macro inside function

**URL:** https://discourse.julialang.org/t/problem-evaluating-symbol-for-macro-inside-function/30142
**Category:** General Usage
**Tags:** macros
**Created:** [October 21, 2019, 6:17pm UTC](https://discourse.julialang.org/t/problem-evaluating-symbol-for-macro-inside-function/30142 "2019-10-21T18:17:01Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)
#### Post date: [February 11, 2020, 2:37pm UTC](https://discourse.julialang.org/t/problem-evaluating-symbol-for-macro-inside-function/30142/5 "2020-02-11T14:37:18Z")

</div>

Never mind, I found out about `Base.@locals`, which solved this nicely!

> [@Using Symbol within function (unexpected behaviour)](https://discourse.julialang.org/t/using-symbol-within-function-unexpected-behaviour/24029/2):
>
> eval() always operates in global scope. Check out the help text: help?\> eval ... eval(expr) Evaluate an expression in the global scope of the containing module. ... Since eval() operates in global scope, it does not have access to the values of your local variables. Since Julia 1.1, though, we have the Base.@locals() macro, which gives you a dictionary mapping local variable names to their local values. Your use case might be a good fit for that: julia\> function foo() a = 1 …

---

_[View the full topic](https://discourse.julialang.org/t/problem-evaluating-symbol-for-macro-inside-function/30142)._
