JuliaLang/julia — pull request #721 by carlobaldassi (2012-04-15 16:33:27+00:00)
Title: make sub() behave like ref()

i.e. drop trailing singleton dimensions, as discussed [here](https://groups.google.com/forum/?fromgroups#!topic/julia-dev/GNZ4w78sZ94).

Example:

```
julia> a = rand(2, 3, 2)
2x3x2 Float64 Array:
[:, :, 1] =
0.121652 0.232535 0.0812166
0.347117 0.224052 0.885407

[:, :, 2] =
0.626699 0.342665 0.163809
0.253675 0.659507 0.922081

julia> sub(a, 1:2, 2, 1)
2-element SubArray of 2x3x2 Float64 Array:
0.232535
0.224052
```

I think it's correct, but since it's not a trivial change, I'll leave it here for review/further discussion instead of pushing it directly.
Also, there's still a difference in behaviour, since `sub` still only allows either 1 index or the same number of indices as the parent array, but I think it was decided it's `ref` which has to change in that case.