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

Simplify A[1, end] lowering with lastindex(A, n) #25763

Merged
merged 3 commits into from
Jan 27, 2018

Conversation

mbauman
Copy link
Sponsor Member

@mbauman mbauman commented Jan 26, 2018

This implements a new method of lastindex to specify a given dimension, and then uses that new method in the lowering of end within multi-dimensional indices. Previously, this would have lowered directly to last(axes(A, d)) for end in position d. Given that axes (and multidimensional indexing generally) are array-centric concepts, I have only implemented this for ::AbstractArray, with a deprecation for all other types suggesting implemention if sensible. I have similarly defined firstindex(A, d) (albeit without the deprecation). It will be available for its syntax transformation in the future.

This implements a new method of `lastindex` to specify a given dimension, and then uses that new method in the lowering of `end` within multi-dimensional indices.  Previously, this would have lowered directly to `last(axes(A, d))` for `end` in position `d`.  Given that `axes` (and multidimensional indexing generally) are array-centric concepts, I have only implemented this for `::AbstractArray`, with a deprecation for all other types suggesting implemention if sensible.  I have similarly defined `firstindex(A, d)` - it will be available for its syntax transformation in the future.
@mbauman mbauman added compiler:lowering Syntax lowering (compiler front end, 2nd stage) domain:arrays [a, r, r, a, y, s] needs news A NEWS entry is required for this change labels Jan 26, 2018
@mbauman mbauman removed the needs news A NEWS entry is required for this change label Jan 26, 2018
@@ -90,16 +90,16 @@
;; the array `a` in the `n`th index.
;; `tuples` are a list of the splatted arguments that precede index `n`
;; `last` = is this last index?
;; returns a call to lastindex(a) or last(axes(a,n))
;; returns a call to lastindex(a) or lastindex(a,n))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

superfluous close paren

@JeffBezanson JeffBezanson merged commit eea727c into master Jan 27, 2018
@JeffBezanson JeffBezanson deleted the mb/simplerlastindex branch January 27, 2018 08:16
Keno added a commit that referenced this pull request Jan 29, 2018
This attempts to address some of the performance regressions observed
with the Stateful iterator #25763. It gets most of the way there,
but unfortunately still ends up allocating the `Stateful` iterator
object rather than propagating through the fields. Getting the rest
of the way there will require some compiler tweaks.
@Keno Keno mentioned this pull request Jan 29, 2018
mbauman added a commit that referenced this pull request Feb 8, 2018
JeffBezanson pushed a commit that referenced this pull request Feb 9, 2018
@nalimilan
Copy link
Member

It would be nice to document the new methods. Also n would probably better be spelled d (as in NEWS.md), and typed as ::Integer?

@nalimilan nalimilan added the needs docs Documentation for this change is required label Mar 6, 2018
@mbauman mbauman removed the needs docs Documentation for this change is required label Mar 7, 2018
@musm
Copy link
Contributor

musm commented Aug 17, 2018

Just a heads up this is missing a deprecation for the rename of endof

@mbauman
Copy link
Sponsor Member Author

mbauman commented Aug 17, 2018

This does implement a deprecation. Are you referring to a deprecation of endof? That is also deprecated at call sites (#23354). Now, extending endof isn't deprecated, but that's a trade-off for better line information with the options we have.

@musm
Copy link
Contributor

musm commented Aug 17, 2018

I see, that makes sense as to why I was not getting the deprecation. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage) domain:arrays [a, r, r, a, y, s]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants