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

What to do about the new oneto and unitrange methods #40284

Open
KristofferC opened this issue Mar 31, 2021 · 2 comments
Open

What to do about the new oneto and unitrange methods #40284

KristofferC opened this issue Mar 31, 2021 · 2 comments
Labels
design Design of APIs or of the language itself ranges Everything AbstractRange

Comments

@KristofferC
Copy link
Member

In #37741, the constructors OneTo and UnitRange were replaced for the generic functions oneto and unitrange in various places. These functions only have one implementation in Base which is that they call their respective constructor. The reason for this seems to be so that the InfiniteArrays.jl package can overload these methods to "hook into" various parts of Julia to support some custom behavior.

One issue with this is that these new methods are completely undocumented and unspecified so it becomes quite confusing when someone edits the code where these methods are. Superficially, it looks like they can be completely removed since they only have a trivial method and are not exposed as public API. The aforementioned PR also caused a regression (#40277) but fixing this is now harder because it is unclear what these methods actually need to do.

It would be good if these methods can be removed so that there is no "unofficial" API that packages hook into. From what I understand the reason these got added had something to do with reducing invalidations but doing so shouldn't really need to expose new API?

cc @dlfivefifty, @timholy

@dlfivefifty
Copy link
Contributor

unitrange can be removed with a bit of redesign. oneto is necessary to support InfiniteArrays.jl without having to do an illegal overload of OneTo .

The rational for adding it is exactly the same as adding the functionality that supported OffsetArrays.jl. And your argument for removal would also apply to removing all features that support OffsetArrays.jl, which are also not included in Base and required many “confusing” hooks. Removing oneto will also break literally all of ApproxFun.jl infrastructure

@dlfivefifty
Copy link
Contributor

Also, the addition of oneto should not have caused the issues with vcat, rather the changes to concat.jl. Possibly the change to mapreduce instead of a for loop to determine the length. I’ll look into it

@nsajko nsajko added ranges Everything AbstractRange design Design of APIs or of the language itself labels Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Design of APIs or of the language itself ranges Everything AbstractRange
Projects
None yet
Development

No branches or pull requests

3 participants