Consider:

julia> function foo()
       f() = nothing
       target = :g
       name = :f
       @eval $target = cfunction($name, Nothing, ())
       end
foo (generic function with 1 method)


julia> foo()
ERROR: f not defined
 in foo at none:5


and

julia> f() = nothing
f (generic function with 1 method)


julia> target = :g
:g


julia> name = :f
:f


julia> @eval $target = cfunction($name, Nothing, ())
Ptr{Void} @0x0000000113b4ba50


I suspect this is because eval is trying to define f at top-level, but is 
there any way to define g in the first example so that it can be used in 
foo?

Reply via email to