Eval from macro

Macros and metaprogramming in julia can be a powerful tool, but it is a good idea to only use macros where there’s no other option. I’m not sure what you trying to do, besides loading CSV. So, can’t you just using CSV, instead?

Another thing, using eval inside a macro is not a good practice, because the macro run a parse time. Instead of eval’ing the expression inside the macro, you should return it. So, to correct your macro, you should rewrite as:

macro my_eval(pkg)
    :(using $pkg)
end

But again, what would be the point of such macro if you can just write using pkg?

2 Likes