# How \`JuMP.@expression\` will work ? / Multiple macros

**URL:** https://discourse.julialang.org/t/how-jump-expression-will-work-multiple-macros/77585
**Category:** Optimization (Mathematical)
**Tags:** question, jump, macros
**Created:** [March 8, 2022, 1:28pm UTC](https://discourse.julialang.org/t/how-jump-expression-will-work-multiple-macros/77585 "2022-03-08T13:28:21Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![iAnkiit](https://avatars.discourse-cdn.com/v4/letter/i/c67d28/32.png) [@iAnkiit](https://discourse.julialang.org/u/iAnkiit)
#### Post date: [March 8, 2022, 1:28pm UTC](https://discourse.julialang.org/t/how-jump-expression-will-work-multiple-macros/77585/1 "2022-03-08T13:28:21Z")

</div>

I am referring a code in which there are multiple macros with same name. So, how would it work? I mean, what attributes would be called/run when macro is called?  
_eg. @expression(EP, ePowerBalance[t=1:T, z=1:Z], 0), @expression(EP, eObj, 0)_  
and many more _“@expression”_ are there.

[**Genx:** Code I am talking about](https://github.com/GenXProject/GenX/blob/main/src/model/generate_model.jl)

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [March 8, 2022, 2:18pm UTC](https://discourse.julialang.org/t/how-jump-expression-will-work-multiple-macros/77585/2 "2022-03-08T14:18:12Z")

</div>

The documentation of `JuMP.@expression` is [`here`](https://jump.dev/JuMP.jl/dev/reference/expressions/#Macros). The code is a little hard to follow but it is [here](https://github.com/jump-dev/JuMP.jl/blob/2875bd1a0d336215a63ffb0fe74ffaaad0a6979a/src/macros.jl#L1309--l1356). I am not sure if I understand your question, what incompatibly are you seeing in calling `@expression` multiple times? Most macros can be called an unlimited number of times inside a function, see `@show` for example.

I thought of re-categorizing your post to the mathematical modeling section, but I am a bit puzzled if your problem is with macros in general or just the `JuMP.@expression` macro specifically.

---

<div class="post-metadata">

### Author: ![iAnkiit](https://avatars.discourse-cdn.com/v4/letter/i/c67d28/32.png) [@iAnkiit](https://discourse.julialang.org/u/iAnkiit)
#### Post date: [March 9, 2022, 8:42am UTC](https://discourse.julialang.org/t/how-jump-expression-will-work-multiple-macros/77585/3 "2022-03-09T08:42:42Z")

</div>

Yes. I figured it out,  
It was about JuMP.@expression.  
Thanks.

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [March 9, 2022, 6:06pm UTC](https://discourse.julialang.org/t/how-jump-expression-will-work-multiple-macros/77585/4 "2022-03-09T18:06:26Z")

</div>

Re-categorized, renamed, and re-tagged your question.
