As an experiment I wrote a simple macro to set a variable:

macro createVar(name, value)
  eval(quote
    $name = $value;
  end)
end

which works as expected:

@createVar foobar 5;
println("foobar = $foobar"); # "foobar = 5" (OK)

However, if I instead do:

macro createVar(name, value)
  quote
    $name = $value;
  end
end

expr = @createVar(foobar, 5);

println("$expr"); # "foobar = 5" (OK)

# now evaluate the expression to do the actual assignment
eval(expr);
println("foobar = $foobar");

I get "ERROR: foobar not defined". I would expect that if I do the eval 
outside of the macro I should get the same result as doing the eval inside 
the macro. Is this expected behavior?

I should add that I'm using a version of 0.3 from the repository.

Reply via email to