# How to replace macro argument with expr as being typed manually?

**URL:** https://discourse.julialang.org/t/how-to-replace-macro-argument-with-expr-as-being-typed-manually/26630
**Category:** New to Julia
**Tags:** question
**Created:** [July 22, 2019, 1:56pm UTC](https://discourse.julialang.org/t/how-to-replace-macro-argument-with-expr-as-being-typed-manually/26630 "2019-07-22T13:56:30Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)
#### Post date: [July 22, 2019, 3:41pm UTC](https://discourse.julialang.org/t/how-to-replace-macro-argument-with-expr-as-being-typed-manually/26630/4 "2019-07-22T15:41:08Z")

</div>

So I assume you want to include an affine or quadratic expression within a nonlinear objective? And you followed the work-around in the docs? [Nonlinear Modeling · JuMP](http://www.juliaopt.org/JuMP.jl/v0.19.2/nlp/#Syntax-notes-1)

At present, the work-around is recommended:

```nohighlight
function create_eq(model, x, arr)
    aux = @variable(model)
    @constraint(model, aux == sum((x - i)^2 for i in arr))
    return aux
end

model = Model()
@variable(model, x)
ex = create_eq(model, x, [1, 2, 3])
@NLobjective(model, Min, ex)

```

Also, please read [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757), and provide a minimal working example.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-replace-macro-argument-with-expr-as-being-typed-manually/26630)._
