>
> Macros are functions evaluated at parse-time.  The runtime scope doesn't 
> even exist when the macro is called.

 
That's right, the answer may well have nothing to do with marcos (maybe I 
obscured the question by even mentioning them in an attempt to give bigger 
context to what I'm trying to accomplish). 

I guess it really boils to just "is there a way to eval something in the 
current scope". Not knowing much about the internals of all of this, given 
that "eval" does exactly that in the global scope, I guess it wouldn't seem 
like such a stretch that something exists for the current scope. For 
example, in Python it exists, 

In [1]: def f(x):
   ...:     return eval("x+1")


In [2]: f(3)
Out[2]: 4



But perhaps the JIT requirements make it impossible in Julia? 

julia> function f(x)
          eval(:(x+1))
       end
f (generic function with 1 method)


julia> f(3)
ERROR: UndefVarError: x not defined
 in eval(::Module, ::Any) at ./boot.jl:234
 in f(::Int64) at ./REPL[1]:2



Reply via email to