This is an intentional design choice. If you want to sent a local variable, you can generate the entire function that does the setting, eval that definition and then use it.
On Mon, Nov 2, 2015 at 6:08 PM, Yichao Yu <[email protected]> wrote: > On Mon, Nov 2, 2015 at 12:52 PM, Deniz Yuret <[email protected]> wrote: > > If I have the following function: > > > > function foo(k,v) > > @eval ($(symbol(k))=$v) > > println(bar) > > end > > > > > > and I call it with: > > > > foo("bar", 5) > > > > then the global variable bar is set to 5 and the function prints 5. > > > > Is there any way to make @eval set a local variable inside foo instead? > (I > > tried prefixing the assignment with local which didn't work). > > No. You can't construct arbitrary expressions at runtime and hope the > compiler to reason about what you constructed. > > > > > thanks, > > deniz > > >
