Actually, the bang (!) ending of function names is just a convention - it 
doesn't make the function do anything special, or treat it any other way 
than without the bang. For example, with the definition

```
push = push!
```

you could very well do `push(a, 3)` to append `3` at the end of the array 
`a`, with precisely the same effect as if you'd done `push!(a,3)`. If you 
write a new function that mutates its arguments, it is conventional to use 
the bang regardless of if the mutated argument is e.g. array or some other 
composite type.

However, while this convention is indeed very old, there's probably old 
code lying around where it isn't used, and other new code where the author 
forgot or was too lazy to make sure all mutating function names ended in 
with a bang. And still today this convention is not enforced in any way: 
it's perfectly legal to define a new mutating function without a bang at 
the end of the name. There is, however, some vaguely related discussion 
about introducing for example notation for pure functions 
<https://github.com/JuliaLang/julia/issues/414>, that might spill over on 
this convention if it is included in the language.

// T

On Friday, June 13, 2014 4:08:17 AM UTC+2, K leo wrote:
>
> Thanks. 
>
> It says this: 
> "By convention, function names ending with an exclamation point (!) 
> modify their arguments. Some functions have both modifying (e.g., sort!) 
> and non-modifying (sort) versions." 
>
> But my experience is a little inconsistent.  I noticed that is what it 
> does to array arguments, but to other arguments (like composite types) 
> it seems not necessary.  Am I missing something? 
>
> Also, it is a special character.  So perhaps it is better listed under 
> operators section in the documentation. 
>
> On 06/13/2014 09:58 AM, Jacob Quinn wrote: 
> > It's mentioned here in the "Some general notes" section, but if you 
> > have suggestions of other places it should be mentioned, I'm sure it 
> > wouldn't hurt! 
> > 
> > http://docs.julialang.org/en/latest/stdlib/base/#introduction 
> > 
> > -Jacob 
> > 
> > 
> > On Thu, Jun 12, 2014 at 9:53 PM, cnbiz850 <[email protected] 
> <javascript:> 
> > <mailto:[email protected] <javascript:>>> wrote: 
> > 
> >     Can't find a description.  I guess that when it is used after a 
> >     function name it makes the modified array argument passed back to 
> >     the caller.  Is that right, or is that all it is used for? 
> > 
> > 
>
>

Reply via email to