# In place with multiple modified arguments

**URL:** <https://discourse.julialang.org/t/in-place-with-multiple-modified-arguments/10730>\
**Category:** General Usage\
**Created:** [May 5, 2018, 7:32pm UTC](https://discourse.julialang.org/t/in-place-with-multiple-modified-arguments/10730 "2018-05-05T19:32:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gideonsimpson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gideonsimpson/32/1928_2.png) [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Post date:** [May 5, 2018, 7:32pm UTC](https://discourse.julialang.org/t/in-place-with-multiple-modified-arguments/10730/1 "2018-05-05T19:32:40Z")

</div>

Is it valid to do in place operations on multiple arguments? I’m interested in writing a function of the form:

```julia
function f!(x,y,p)
# commands which change x and y
x,y
end

```

where `x` and `y` are modified and `p` is some set of additional parameters.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [May 5, 2018, 7:49pm UTC](https://discourse.julialang.org/t/in-place-with-multiple-modified-arguments/10730/2 "2018-05-05T19:49:01Z")

</div>

> [@gideonsimpson](#):
>
> Is it valid to do in place operations on multiple arguments?

Yes, appending `!` is just a convention to signal that the function modifies some of its arguments, not which one(s). I would suggest that you add a docstring and/or comment that describes which arguments the function modifies.

---

<div class="post-metadata">

**Author:** ![foobar\_lv2](https://avatars.discourse-cdn.com/v4/letter/f/ee59a6/32.png) [@foobar\_lv2](https://discourse.julialang.org/u/foobar_lv2)\
**Post date:** [May 5, 2018, 9:30pm UTC](https://discourse.julialang.org/t/in-place-with-multiple-modified-arguments/10730/3 "2018-05-05T21:30:15Z")

</div>

There was also some discussion of signaling the intent of mutating arguments by writing

```julia
function f!(x!,y!,p)
# commands which change x! and y!
x!,y!
end

```

This makes it abundantly clear which variables are mutated, even if you don’t write proper documentation: Both the help, via `help?> f!`, and `methods(f!)` show the formal argument names. Julia programmers who have never seen this before will instantly understand what you are trying to communicate with this.

Disadvantages: May look ugly (matter of taste). If used very inconsistently, people might mistakenly assume that arguments without exclamation marks are not mutated. Not widely used as a convention, and fracturing the coding style is never good for an ecosystem.
