JuliaLang/julia — pull request #3814 by timholy (2013-07-24 07:06:54+00:00)
Title: Implement get() for SubArrays

This implements `get()` for `SubArray`s, with the behavior that "missing" values are looked up in the parent:
```
julia> A = reshape(1:40, 5, 8)
5x8 Int64 Array:
1 6 11 16 21 26 31 36
2 7 12 17 22 27 32 37
3 8 13 18 23 28 33 38
4 9 14 19 24 29 34 39
5 10 15 20 25 30 35 40

julia> sA = sub(A, 2:5, 3:7)
4x5 SubArray of 5x8 Int64 Array:
12 17 22 27 32
13 18 23 28 33
14 19 24 29 34
15 20 25 30 35

julia> get(sA, (2:4, -1:7), NaN)
3x9 Float64 Array:
3.0 8.0 13.0 18.0 23.0 28.0 33.0 38.0 NaN
4.0 9.0 14.0 19.0 24.0 29.0 34.0 39.0 NaN
5.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 NaN
```

Main points to check:

- Renaming get->get! for the preallocated output, plus deprecation & exports change
- Should we disable linear-indexing for `get()` for arrays of dimension > 1? In the context of this behavior for `SubArray`s, there does not appear to be any reasonable interpretation for this operation.