<p dir="auto">With the proposal for <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="243831362" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/22858" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/julia/issues/22858/hovercard" href="https://github.com/JuliaLang/julia/issues/22858">#22858</a>, I've been thinking it could be useful to have a type which commonly represents "AllIndices". So <code class="notranslate">A[AllIndices()]</code> would return <code class="notranslate">A</code>, making it the identity indexing element in some sense.</p>
<p dir="auto">The reason is so that this could handle non-standard indexing. In some algorithms you might want the user to specify some indices that they "want to save", and you can default to <code class="notranslate">AllIndices</code>. In many of these cases, you haven't built the array yet and may be getting a non-standard type from the user, so defaulting to <code class="notranslate">eachindex</code> or something like that isn't possible. Currently a way to handle this is to default the chosen indices to <code class="notranslate">nothing</code>, and if you see <code class="notranslate">nothing</code> you treat it as <code class="notranslate">AllIndices</code> applied to the type by iterating <code class="notranslate">eachindex</code> after the array is built.</p>
<p dir="auto">The name could change of course.</p>
<p dir="auto">Numpy has this ellipsis notation for filling<br>
index tuples up to dimension, where in<br>
<code class="notranslate">A[..., i, k]</code><br>
<code class="notranslate">...</code> is interpreted as shorthand for the number of colons <code class="notranslate">:, :, : etc</code>  needed to fill<br>
the indexing tuple up to dimension <code class="notranslate">n</code>.</p>
<p dir="auto"><a href="http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html" rel="nofollow">http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html</a></p>
<p dir="auto">This gives nice access to contiguous subarrays in the dense array case and would be not more harmful than the <code class="notranslate">:</code> notation itself.</p>
<p dir="auto">Was this feature already considered? It was mentioned by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/toivoh/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/toivoh">@toivoh</a> on the mailing list, but did not trigger discussion.</p>