# Ordinal Indexing as a Language Feature

**URL:** https://discourse.julialang.org/t/ordinal-indexing-as-a-language-feature/91970
**Category:** Internals & Design
**Created:** [December 21, 2022, 5:07pm UTC](https://discourse.julialang.org/t/ordinal-indexing-as-a-language-feature/91970 "2022-12-21T17:07:56Z")
**Posts on this page:** 1
**Showing post:** 28

<div class="post-metadata">

### Author: ![uniment](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uniment/32/24532_2.png) [@uniment](https://discourse.julialang.org/u/uniment)
#### Post date: [January 9, 2023, 7:45pm UTC](https://discourse.julialang.org/t/ordinal-indexing-as-a-language-feature/91970/28 "2023-01-09T19:45:15Z")

</div>

Indeed `OffsetArrays.no_offset_view` produces exactly this idea, but that doesn’t solve the issue that gets some people to ponder [whether OffsetArrays.jl is a poison pill](https://discourse.julialang.org/t/is-offsetarrays-jl-a-poison-pill/85188/). Namely, we would ideally have _something in_ `Base` _which offers assurance that 1-based indices will work on an arbitrary_ `AbstractArray`.

This is exactly what OrdinalIndices.jl provides by offering an _ordinal index type_. I’m toying with the alternative approach of using an _ordinally indexed view_, that `ordinal(A)` will be a 1-based-indexed view of `A`.

Apparently this idea was already [pondered here](https://discourse.julialang.org/t/is-offsetarrays-jl-a-poison-pill/85188/21) but deserves more exploration imo. It would be really easy to add it to the `AbstractArray` specification, and the fallback method is the easiest thing in the world.

```julia
ordinal(A::AbstractArray) = A

```

this would place the burden on `OffsetArrays` to add the method:

```julia
ordinal(A::OffsetArray) = ordinal(OffsetArrays.no_offset_view(A))

```

---

_[View the full topic](https://discourse.julialang.org/t/ordinal-indexing-as-a-language-feature/91970)._
