`eval` operates in global scope only:
http://docs.julialang.org/en/release-0.4/manual/metaprogramming/#eval-and-effects

On Tue, Nov 24, 2015 at 1:12 PM, Pieterjan Robbe <pieterjanro...@gmail.com>
wrote:

> Why can't I parse a function evaluation of a function defined within the
> scope of another function?
> i.e., the following terminates with an UndefVarError: bar not defined:
>
> *function* foo()
>   *function* bar()
>     x
>   end
>   *return* eval(parse("bar()"))
> end
>
> x = 7
> foo()
>
> However, I can do
>
> *function* foo()
>   *function* bar()
>     x
>   end
>   *return* bar()
> end
>
> x = 7
> foo()
>
> and
>
> *function* foo()
>   *return* eval(parse("bar()"))
> end
>
> *function* bar()
>   x
> end
>
> x = 7
> foo()
>
> Many thanks!
> -Pieterjan
>

Reply via email to