# RFC: Language Support for Traits — Yay or Nay?

**URL:** <https://discourse.julialang.org/t/rfc-language-support-for-traits-yay-or-nay/93914>\
**Category:** Internals & Design\
**Tags:** question, proposal, inheritance, traits, interface\
**Created:** [February 2, 2023, 11:10am UTC](https://discourse.julialang.org/t/rfc-language-support-for-traits-yay-or-nay/93914 "2023-02-02T11:10:06Z")\
**Posts on this page:** 1\
**Showing post:** 23

<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:** [February 3, 2023, 7:43pm UTC](https://discourse.julialang.org/t/rfc-language-support-for-traits-yay-or-nay/93914/23 "2023-02-03T19:43:31Z")

</div>

> [@Steven\_Sagaert](#):
>
> generic indexing or 1-based indexing

I actually don’t think traits are the right solution for this one. I think this is better addressed by instead making it easier to use 1-based indices to access containers without 1-based indices, so that 1-based indexing can be considered “generic” again.

One idea is to make a _1-based index type_, as illustrated by the [OrdinalIndexing.jl](https://github.com/jishnub/OrdinalIndexing.jl) package: e.g., `v[1st]`, `v[2nd]`, `v[(1:5)th]`. Such indices offer a 1-based indexing assurance.

Another idea is to make a _1-based indexing view_, as @DNF ponders in [this post](https://discourse.julialang.org/t/is-offsetarrays-jl-a-poison-pill/85188/21): e.g. `OneBasedView(v)[1:5]`. This seems inconvenient, but to illustrate how it’s not so bad: you could write a function like this:

```julia
hermitian!(A) = let A = OneBasedView(A), (m, n) = size(A)
    m == n || error("Matrix must be square")
    @inbounds for i = 1:m, j = i:n
        A[i, j] = A[i, j] + A[j, i]'
        A[j, i] = A[i, j]'
    end
end

```

Notice that `OneBasedView` is called only once at the top, and the rest of the function accesses `A` through this view.

These possibilities are also pondered in [this thread](https://discourse.julialang.org/t/ordinal-indexing-as-a-language-feature/91970).

---

_[View the full topic](https://discourse.julialang.org/t/rfc-language-support-for-traits-yay-or-nay/93914)._
