JuliaLang/julia — pull request #4782 by stevengj (2013-11-11 17:14:02+00:00)
Title: support multi-arg push! and unshift!

This patch extends `push!` and `unshift!` to accept multiple arguments: `push!(A, items...)` and `unshift!(A, items...)`, whenever the 1-item versions are defined. For example:
```
julia> push!([1,2,3], 4,5)
5-element Array{Int64,1}:
1
2
3
4
5

julia> unshift!([1,2,3], 4,5)
5-element Array{Int64,1}:
4
5
1
2
3
```
Note that the ordering of the arguments is the same as their ordering in the resulting array (so the items are pushed from left to right, but unshifted from right to left). This seems sensible to me (changing the ordering is a bit surprising), it mirrors `append!` and `prepend!`, and e.g. the Javascript push/unshift functions have the same semantics.

By default, these are implemented in terms of the 1-item versions. Specific types could, of course, define specialized multi-argument versions, e.g. `push!(A::Array, items...)` could be defined to grow the array by several items at once and avoid overhead. But this is an optimization that can be done later if it seems important. The main thing is that this patch does not introduce any performance regressions, it just increases convenience.