# Modifier Function Naming Style

**URL:** <https://discourse.julialang.org/t/modifier-function-naming-style/5047>\
**Category:** General Usage\
**Tags:** first-steps\
**Created:** [July 25, 2017, 1:25am UTC](https://discourse.julialang.org/t/modifier-function-naming-style/5047 "2017-07-25T01:25:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![clinton](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@clinton](https://discourse.julialang.org/u/clinton)\
**Post date:** [July 25, 2017, 1:25am UTC](https://discourse.julialang.org/t/modifier-function-naming-style/5047/1 "2017-07-25T01:25:32Z")

</div>

Say I have the following trivial function:

```julia
function foo(A, x, b=Vector{Float64}(length(x)))
  b .= A * x
  return b
end

```

My question is, should the function be named foo, foo!, or should I break this into two functions? While this is mainly a style question, I’d be happy to hear of any performance considerations regarding having this as one versus two functions.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [July 25, 2017, 2:13am UTC](https://discourse.julialang.org/t/modifier-function-naming-style/5047/2 "2017-07-25T02:13:31Z")

</div>

> [@clinton](#):
>
> b .= A \* x

Make that `A_mul_B!(b,A,x)` if you want that to be non-allocating. The function you wrote is essentially `A_mul_B!` with a default arg. The weird thing is that normally the mutated variable goes first. But there’s no performance issues with this. Though I would change the header to have `b=similar(x)`

---

<div class="post-metadata">

**Author:** ![clinton](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@clinton](https://discourse.julialang.org/u/clinton)\
**Post date:** [July 25, 2017, 2:17am UTC](https://discourse.julialang.org/t/modifier-function-naming-style/5047/3 "2017-07-25T02:17:11Z")

</div>

Nice, thanks! I didn’t know about similar(.), that will be useful.
