JuliaLang/julia — pull request #3861 by stevengj (2013-07-28 18:13:16+00:00)
Title: don't require subclasses of AbstractVector/Matrix to implement more than 1d/2d indexing

Currently, a subclass of `AbstractVector` has to implement `getindex` for arbitrarily many indices, or `repl_show` breaks as illustrated by the example below. This is annoying and somewhat counter-intuitive. The attached patch fixes this, so that multidimensional `getindex` and `setindex!` are provided automatically for `AbstractVector` and `AbstractMatrix`. (Not sure if there is a good way to do this more generally.)

For example, before my patch is applied, the following code
```
type Foo{T} <: AbstractVector{T}
v::Vector{T}
end
import Base: size, getindex
size(x::Foo) = size(x.v)
getindex(x::Foo, i::Integer) = x.v[i]
repl_show(Foo([1,2,3]))
```
leads to the surprising output
```
3-element Int64 Foo:
#undef
#undef
#undef
```