Order of arguments in mutating functions

I’m sure this has been asked before, but my searches came up empty. I have a function F that takes another function f and an array A as input. The function mutates A.

So is the order

F!(f,A) or F!(A,f)

The manual says

  1. Function argument. Putting a function argument first permits the
    use of do blocks for passing multiline anonymous functions.

  2. Input being mutated. For example, in fill!(x, v), x is the
    object being mutated and it appears before the value to be inserted into x.

So do I pick item 1 or item 3? I am leaning toward 1, but am not sure that is the correct thing.

I personally find F!(f,A) to be more clear.

Putting the function first normally takes priority over mutating arguments to support do syntax.

3 Likes

An example in the Base library is

filter!(f, A)
2 Likes