-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Create @view
macro for creating SubArrays via indexing.
#16564
Conversation
end | ||
|
||
""" | ||
@sub A[...] |
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.
should be added to rst docs somewhere if exported
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.
How do I do that? I couldn't figure it out.
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.
It's somewhat documented in CONTRIBUTING.md I think. The gist of it is pick a place for it in the rst, add just the signature, then make docs
should fill in the rest.
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.
Great, thanks.
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.
Done.
hm what was it about |
Nice! Some previous discussion is buried in the Arraypocalype issue and starts here: #13157 (comment) One question is if the macro should recurse through all non-assignment refs or not. I think I'd prefer the recursive behavior, allowing for |
Recursive behaviour is more complicated, and we would need to figure out some possible ambiguities like: @sub A[B[2:end]] Should that create subarrays of both I figured this was a reasonable start, and recursive behaviour could be added later. |
I'm not sure, but this might require input from someone who knows more about the internals. |
I think I was just misreading the caveats about the macro option from the long discussion, it was warned that you'd have to reimplement the |
""" | ||
@sub A[inds...] | ||
|
||
Creates `SubArray` from an indexing expression. This can only be applied directly to a |
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.
"Creates a SubArray
"
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.
good catch.
#15750 is relevant: use first/last as endpoints for Range indexing |
The point has always been that we couldn't handle I should also point out that Jeff has made a related proposal, adding |
The thought just occurred to me that we could use |
There's some sentiment in #13157 that this might be better named |
I originally proposed it as |
Also worth providing a link to the original inspiration JuliaArrays/ArrayViews.jl#14 (which I had forgotten). |
@sub
macro for creating SubArrays via indexing.@view
macro for creating SubArrays via indexing.
I've renamed to |
Merge? |
Allows writing things like
In order to replicate current indexing behaviour, this actually calls
slice
.I'm fairly confident this replicates the
end
replacing behaviour injulia/src/julia-syntax.scm
Lines 93 to 123 in c43b5e5
This was discussed in an issue at some point, but I forgot which one.