Using a macro to define two methods at once?

there is a way to define two methods of a function with a macro?, for example, a macro like this:

f = @mymacro (2,3)

that generates the following code:

f(x) = 2*x
f(x,y) = 2*x+3*y

the example is simple and what i’m looking is different, but the key is to generate two methods for f, using a different amount of variables

1 Like

As always with a macro, you need to write code that will return a Julia expression object corresponding to the code you want to be compiled. In this case that expression object should correspond to defining these two functions. You can do this eg inside a quote…end block.

I have a macro here
that takes a definition like f(x::T1,y::T2) and defines both that and f(y::T2, x::T1)