# Convention for read-only array getters

**URL:** <https://discourse.julialang.org/t/convention-for-read-only-array-getters/19356>\
**Category:** Internals & Design\
**Created:** [January 7, 2019, 3:56pm UTC](https://discourse.julialang.org/t/convention-for-read-only-array-getters/19356 "2019-01-07T15:56:15Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [January 20, 2019, 4:29pm UTC](https://discourse.julialang.org/t/convention-for-read-only-array-getters/19356/22 "2019-01-20T16:29:46Z")

</div>

I have created a repo that is a baseline specification of what was discussed [GitHub - bkamins/ReadOnlyArrays.jl: A wrapper type around AbstractArray that is read-only](https://github.com/bkamins/ReadOnlyArrays.jl). I came to the conclusion not to include indexing when creating the read-only array, as we can always wrap a view if needed.

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [January 25, 2019, 11:37am UTC](https://discourse.julialang.org/t/convention-for-read-only-array-getters/19356/23 "2019-01-25T11:37:28Z")

</div>

As we are considering including [GitHub - bkamins/ReadOnlyArrays.jl: A wrapper type around AbstractArray that is read-only](https://github.com/bkamins/ReadOnlyArrays.jl) in DataFrames.jl and CategoricalArrays.jl we want to make sure that we would follow a more widely accepted approach. Therefore it would be great if we got the feedback from the community in the following areas:

1. is the provided functionality useful (of course the details can be changed later);
2. if yes then where it should be kept:  
a. as is  
b. the repo should be moved to some organization on GitHub, as a separate package  
c. the functionality should be included in some existing package

Tank you.

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [January 31, 2019, 4:39pm UTC](https://discourse.julialang.org/t/convention-for-read-only-array-getters/19356/24 "2019-01-31T16:39:29Z")

</div>

I gave it a glance (heading out). People getting a ReadOnlyArray may not know that it is a ReadOnlyArray even though they will not write it. For that reason, please assure that the usual `view, @view` constructs (as may be appropriate) passthru or subselect a view/ReadOnlyArray as the client invocation indicates.

Consider asking `JuliaArrays` if they would be a suitable home (and one that would facilitate overall alignment with future intent).

---

<div class="post-metadata">

**Author:** ![bkamins](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bkamins/32/208538_2.png) [@bkamins](https://discourse.julialang.org/u/bkamins)\
**Post date:** [January 31, 2019, 5:40pm UTC](https://discourse.julialang.org/t/convention-for-read-only-array-getters/19356/25 "2019-01-31T17:40:16Z")

</div>

Thank you for the comment.

Regarding:

> [@JeffreySarnoff](#):
>
> please assure that the usual `view, @view` constructs (as may be appropriate) passthru or subselect a view/ReadOnlyArray as the client invocation indicates.

Do you mean that `view` of `ReadOnlyArray` should create a view of its parent and then wrap it again in `ReadOnlyArray` to avoid excessive nesting of wrappers?

CC @mbauman - any opinion on this?

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [January 31, 2019, 8:29pm UTC](https://discourse.julialang.org/t/convention-for-read-only-array-getters/19356/26 "2019-01-31T20:29:29Z")

</div>

I wouldn’t worry about it. Folks are now used to seeing `view(::ReadOnlyArray, ...)`, for example.

[Previous page](https://discourse.julialang.org/t/convention-for-read-only-array-getters/19356.md?page=1)
