Help with a Macro

macros

#1

Help!
I need to transform function definitions from their normal form

FFF(a::Int64,b::Int64) = a+b)

function FFF(a::A,b::B)
    a+b
    a-b
end

to

const FFF = MultiFunc(:FFF,:Main)
@generated ContextCall{:FFF,:Main,C}(a::A,b::B)) where C = begin
    code = quote
        a+b
        a-b
    end
    Context{C}(code)
end

I managed to use MacroTools to parse the function definition , but I am unable to reconstruct it properly … I got mixed up with all the quote quoting and escaping stuff.
@MikeInnes maybe you can help?

It is for presenting a POC or a “toy” example for handling multiple dispatch differently , in a way that may support
compilation and binary building.


#2

Maybe you can post a link to a gist of what you got so far? I definitely find the escaping, etc. hard, but usually I manage to get there with a bit of trial and error.


#3