-
Notifications
You must be signed in to change notification settings - Fork 40
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
Completely stop pirating Base methods #306
Comments
I'm in favour of removing these convenience methods in |
Great. A wrapper type is how to do this. DimensionalData.jl does similar things without any piracy. |
Perhaps we need to retain the convenience of
In the first case, providing the length is redundant given the axes. The second case is useful if we know the origin, but not as much if we know, say, the endpoint and the length. The missing feature is the ability to construct such an array given just the |
Yes thats exactly how DimensionalData.jl does it. OffsetArrays could be similar.
That screams "This returns an Edit: no Makie.jl exports |
|
Sure, if it's not exported you can have whatever. I was just wondering how to match the convenience of a range, and exporting something might help with that. |
Isn't the existing |
Yes, it seems essentially equivalent, except it doesn't subtype The bigger type-piracy in this package is perhaps in |
well, |
If you want to require But it seems more useful for |
Indeed, I almost always do, because that's the natural reading of the docs. My fundamental point is that a range is not actually an array, not the collection of numbers it can be expanded into, but a promise about constant spacing (and density for
There are of course many others that merely lose efficiency -- e.g.
I have always been suspicious of arithmetic on
Heck, both
This actually works! (except for the typeparameter changing from Bool to Int64 when unspecified, but see previous comment about arithmetic on
|
This may be an issue to raise in Base? Here we have no ability to change the definition of |
Certain parts from this package may be ported to |
Another example of this: Loading OffsetArrays.jl "fixes" a bug in And critically, we test against OffsetArrays.jl, as But this will hide the bug Base functions can pass our test suit and fail in general use because OffsetArrays.jl is loaded in our tests. |
That's a bit unfortunate, although I think this is better fixed in |
I'm not sure |
|
This is another odd one: julia> (1:10)[Base.IdentityUnitRange(5:7)]
5:7
julia> using OffsetArrays
julia> (1:10)[Base.IdentityUnitRange(5:7)]
OffsetArrays.IdOffsetRange(values=5:7, indices=5:7) |
This is technically more consistent, but we should probably stop defining these methods for |
But it's also worse than my example because it's changing the return type of a Base method that did not error. To me this one is really bad. "technically more consistent" can't apply to type piracy, it's by definition technically inconsistent. |
How about a compromise for now: we allow projects to disable the type-piracy in |
In a session where OffsetArrays is a dependency of some package that I'm using, this is very strange to see:
This really should be an error. An
OffsetArray
is not at all what I wanted. I simply made a typo.The main problem with this is it breaks simple mental models for understanding what has gone wrong in arbitrary julia code. Base type + Base method returning a package type should be completely outside of what we expect as a possible behavior.
The text was updated successfully, but these errors were encountered: