Thanks a lot!
There remains a weird issue about globals being mangled by the module name: 
say that all my code is written in a module called "GAP". Assuming I put 
this in the module:

macro do_ccall(f,args...) :(ccall($f, Int, $(Expr(:tuple, [Int for i in 
1:length(args)]...)), $(args...))) end


julia> using GAP

julia> x = GAP.Obj(0);

julia> GAP.@do_ccall(x,1,2,3)
ERROR: UndefVarError: x not defined

julia> macroexpand(:(GAP.@do_ccall(x,1,2,3)))
:(ccall(GAP.x,GAP.Int,(Int64,Int64,Int64),1,2,3))

Ahah... so x got treated as GAP.x. I tried then

:(ccall($(esc(f)), Int, $(Expr(:tuple, [Int for i in 1:length(args)]...)), 
$(args...))) 

and this works now; though if one of the arguments were also x the same 
problems would occur. How should I make sure the code emitted contains 
exactly the binding of its argument (x), and not something else (GAP.x)?

Reply via email to