eval always happens in the global scope — John
On Jul 1, 2014, at 10:15 PM, Cameron Smith <[email protected]> wrote: > Can anyone explain what I am misunderstanding about scope such that > > julia> function foo() > foo2(x) = println(x) > foo2(1); eval(parse("foo2(2)")); > end > foo (generic function with 1 method) > > > julia> foo() > 1 > ERROR: foo2 not defined > in foo at none:3 > > is not the same as > > julia> function foo() > foo2(x) = println(x) > foo2(1); foo2(2); > end > foo (generic function with 1 method) > > > julia> foo() > 1 > 2 > > given, of course, that > > julia> foo2(x) = println(x) > foo2 (generic function with 1 method) > > > julia> eval(parse("foo2(1)")) > 1 >
