thanks. is there a function other than eval that would enable evaluation of 
a string or symbol to result in a call to a nested function?

On Wednesday, July 2, 2014 1:17:07 AM UTC-4, John Myles White wrote:
>
> eval always happens in the global scope
>
>  — John
>
> On Jul 1, 2014, at 10:15 PM, Cameron Smith <[email protected] <javascript:>> 
> 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
>
>
>

Reply via email to