-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
Support IndexStyle, IndexLinear, IndexCartesian #329
Conversation
README.md
Outdated
@@ -101,6 +101,8 @@ Currently, the `@compat` macro supports the following syntaxes: | |||
|
|||
* `bytestring` has been replaced in most cases with additional `String` construction methods; for 0.4 compatibility, the usage involves replacing `bytestring(args...)` with `Compat.String(args...)`. However, for converting a `Ptr{UInt8}` to a string, use the new `unsafe_string(...)` method to make a copy or `unsafe_wrap(String, ...)` to avoid a copy. | |||
|
|||
* In 0.6, older non-exported indexing traits were renamed and exported as `IndexStyle`, `IndexLinear`, and `IndexCartesian`. Any code specializing `Base.linearindexing(::Type{T})` should switch to `Compat.IndexStyle(::Type{T})`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The correct form is ::Type{<:T}
AFAIK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, I was just being brief and didn't want to exclude notation that was valid on 0.5. I'll try to change it to be more explicit about old and new syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but I know I got it wrong the first time, so I would say it's worth being explicit since people are likely to copy/paste the suggested solution. You could use @compat Compat.IndexStyle(::Type{<:T})
(or just use the old syntax).
07c4e8a
to
3678224
Compare
README.md
Outdated
@@ -78,6 +78,8 @@ Currently, the `@compat` macro supports the following syntaxes: | |||
* `@compat A{T} = B{T}` or `@compat const A{T} = B{T}` to declare type alias with free | |||
parameters. [#20500]. Use `const A = B` for type alias without free parameters. | |||
|
|||
* `@compat Compat.IndexStyle(::Type{<:MyArray}) = IndexLinear()` and `@compat Compat.IndexStyle(::Type{<:MyArray}) = IndexCartesian()` to define traits for abstract arrays, replacing the former `Base.linearindexing{T<:MyArray}(::Type{T}) = Base.LinearFast()` and `Base.linearindexing{T<:MyArray}(::Type{T}) = Base.LinearSlow()`, respectively. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or should we allow people to write this as @compat Base.IndexStyle(...)
, effectively lying about which module IndexStyle
is defined in?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say either solution is fine. Base.IndexStyle
might be a bit better since people will just have to remove @compat
to get the official 0.6 syntax, but not a big deal.
3678224
to
d0a74f7
Compare
Tests pass. I have a growing collection of packages for which I have PRs ready to queue, so would be great to merge this soon and tag a new release. |
Was added in #329, now obsolete as no longer required on minimum supported Julia version 0.6.
* Remove at-compat for type aliases Was added in #326, now obsolete as no longer required on minimum supported Julia version 0.6. * Remove at-compat for Nullable construction Was added in #287, now obsolete as no longer required on minimum supported Julia version 0.6. * Remove at-compat for Foo{<:Bar} sugar Was added in #317 (and #336), now obsolete as no longer required on minimum supported Julia version 0.6. * Remove at-compat for index styles Was added in #329, now obsolete as no longer required on minimum supported Julia version 0.6. * Remove at-compat for type declarations Was added in #325, now obsolete as no longer required on minimum supported Julia version 0.6. * Remove unused at-compat helper functions * Remove README entries for removed at-compat functionality * new style call overloading (added in #181, removed in #385) * `get(io, s false)` (added in #212, #215, #225, removed in #385) * `.=` (added in #292 and #316, removed in #372) * Remove `Compat.collect(A)` Was added in #350 and #351, now obsolete as no longer required on minimum supported Julia version 0.6.
Ref JuliaLang/julia#16378.