JuliaLang/julia — pull request #6037 by carlobaldassi (2014-03-03 21:05:48+00:00)
Title: some indexing tweaks

Two independent commits in this PR:

1. fix #6017 by disallowing generic `to_index`, i.e. leaving only `Real` and `AbstractArray{Real}` as valid types. Alternative fixes (e.g. restricting `getindex` signatures) didn't turn out to be practical, and to me the restriction on indexing in general seems reasonable, and won't hopefully break anything: in Base it is always used like that (at times implicitly, as in the case exposed by #6017), and the function is not exported. Of all packages installed on my system, only ArrayViews uses it, and only once without explicitly restricting to `Real` (it's defined on `Ranges`), so I guess this should be safe (cc @lindahua), and to me the restriction seems reasonable. Also, if more exotic needs emerge, it's easy to add specialized `to_index` versions.
2. extend the signature of purely-scalar Array and SubArray indexing in high dimensions, which previously was allowing Reals for dimensions up to 6, and only Ints afterwards. This seems weird to me, but maybe there's something I'm not aware of (cc @JeffBezanson). BTW it's the same in ArrayViews (cc @lindahua).