# Help with a Macro

**URL:** https://discourse.julialang.org/t/help-with-a-macro/11300
**Category:** General Usage
**Tags:** macros
**Created:** [May 31, 2018, 6:50pm UTC](https://discourse.julialang.org/t/help-with-a-macro/11300 "2018-05-31T18:50:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![TsurHerman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tsurherman/32/1234_2.png) [@TsurHerman](https://discourse.julialang.org/u/TsurHerman)
#### Post date: [May 31, 2018, 6:50pm UTC](https://discourse.julialang.org/t/help-with-a-macro/11300/1 "2018-05-31T18:50:58Z")

</div>

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

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

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

```

to

```julia
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.

---

<div class="post-metadata">

### Author: ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)
#### Post date: [May 31, 2018, 8:21pm UTC](https://discourse.julialang.org/t/help-with-a-macro/11300/2 "2018-05-31T20:21:42Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![TsurHerman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tsurherman/32/1234_2.png) [@TsurHerman](https://discourse.julialang.org/u/TsurHerman)
#### Post date: [May 31, 2018, 9:02pm UTC](https://discourse.julialang.org/t/help-with-a-macro/11300/3 "2018-05-31T21:02:49Z")

</div>

[https://gist.github.com/TsurHerman/2ec94d5bc6a361bef79f74aa71aa2740](https://gist.github.com/TsurHerman/2ec94d5bc6a361bef79f74aa71aa2740)
