Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should there be an AbstractOneTo type (with OneTo <: AbstractOneTo) that packages can subtype? #41946

Open
jishnub opened this issue Aug 20, 2021 · 2 comments · May be fixed by #50361
Open

Should there be an AbstractOneTo type (with OneTo <: AbstractOneTo) that packages can subtype? #41946

jishnub opened this issue Aug 20, 2021 · 2 comments · May be fixed by #50361

Comments

@jishnub
Copy link
Contributor

jishnub commented Aug 20, 2021

The OneTo type was introduced keeping OffsetArrays in mind, so that the package may add methods to Base functions such as reshape for AbstractUnitRange arguments, while Base does the same for OneTo. The situation is complicated by StaticArrays adding SOneTo which behaves exactly like a OneTo. The problem with this is that OffsetArrays performs type-piracy, and the behavior of StaticArrays methods might change with OffsetArrays loaded.

The solution to this seems to be to have an AbstractOneTo type in Base, and define the Base methods for AbstractOneTo instead of OneTo. StaticArrays can then subtype AbstractOneTo, and always use Base methods irrespective of whether OffsetArrays is loaded.

@goretkin
Copy link
Contributor

x-ref: #41853

(unify <:AbstractRange by using a generic StepRange with a static start and step)

@chriselrod
Copy link
Contributor

If this were a trait instead, then this could also apply to ArrayInterface.OptionallyStaticUnitRange{StaticInt{1},<:Any} .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants