Hi, I want to create a macro with which I can create a function with a 
custom bit of code:

In the repl I can do a toy example:


*name = :hi*


*vectype = Vector{Int}*


*quote**  function ($name)(v::$vectype)*

    *println("hi")*

  *end*

*end*

However if I try to put this in a macro and use it I get an error:

*macro customFun(vectype::DataType, name::Symbol)*


*  quote**   function ($name)(v::$vectype)*

*      println("hi World!")*

*    end*

*  end*



*end*

*@customFun(Vector{Int}, :hi)*

What am I doing wrong? I'd like to use macro arguments to provide a 
function's name, and the datatype of the argument. I haven't used macros to 
define functions more complex than simple one liners.

Thanks,
Ben.

Reply via email to