I am trying to define this function (with “Int” as a string argument) through a macro
function my_function_name(x::Int) return x*x+one(x) end
Here is my best try (which fails).
I realize this MWE is not meaningful. In my use case, the body of the function will be different (i.e. a different calculation) based on the type of
x (say the output is x^2 for Int32 and x^3 for UInt8).
macro myMacro(tt) name="my_function_name" out= quote function $(esc(Symbol(name)))(x::$tt) return x*x+one(x) end end #end quote return out end @macroexpand @myMacro("Int") @myMacro("Int")