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

Safe non-traditional array indexing #16973

Closed
timholy opened this issue Jun 16, 2016 · 8 comments · Fixed by #17228
Closed

Safe non-traditional array indexing #16973

timholy opened this issue Jun 16, 2016 · 8 comments · Fixed by #17228
Assignees
Labels
arrays [a, r, r, a, y, s]
Milestone

Comments

@timholy
Copy link
Sponsor Member

timholy commented Jun 16, 2016

With reference to #16260 (comment):

  • transitionally (julia-0.5 only) make size and length throw an error for arrays with unconventional indexing
  • introduce @arraysafe to rewrite calls to size and length to something that doesn't throw an error
  • merge allocate_for into similar
@StefanKarpinski
Copy link
Sponsor Member

@timholy, where are we at on this?

@timholy
Copy link
Sponsor Member Author

timholy commented Jul 11, 2016

As far as I'm concerned, all important known issues are closed by one merged PR (#17137) and two open PRs: #17228 and #17355. It would be nice to have a better deprecation for first(::Colon), see discussion starting at #16260 (comment). But once we decide on something it's a couple of lines to implement it. EDIT: it occurs to me that one good strategy would be to deprecate it but not provide a replacement in Base. The warning could link to a section of the devdocs that provides guidance. I would guess that almost all uses would be covered by indexoffset as described in #16260 (comment).

However, I've gotten hints of some discontent, so most importantly see #17338 (comment) and #17228 (comment). FYI the DataArrays breakage is already fixed at JuliaStats/DataArrays.jl#205, with tkelman/DataArrays.jl#2 cued to improve the fix.

@timholy
Copy link
Sponsor Member Author

timholy commented Jul 11, 2016

Oh, if folks are giving this some attention but need some time, my "merge by Monday" can obviously go on hold. I put a deadline on it because it seems like a bad idea to let them sit until moments before julia-0.5RC and THEN decide to either merge or revert (either of which could be disruptive). We should decide soon, but it doesn't have to be today.

@timholy
Copy link
Sponsor Member Author

timholy commented Jul 13, 2016

Since @wildart seems to be coming to completion, I'm inclined to start hitting "merge" on my PRs. Speak now or...

@StefanKarpinski
Copy link
Sponsor Member

I think @JeffBezanson may have a few reservations, so maybe give him a chance to comment.

@timholy
Copy link
Sponsor Member Author

timholy commented Jul 13, 2016

OK, that's the feedback I was waiting for. Silence is very hard to interpret.

@timholy
Copy link
Sponsor Member Author

timholy commented Jul 15, 2016

#17228 seems ready for review. It also includes the revised deprecation for first(::Colon).

I guess there is one potential last dangling issue: what to do, if anything, about #16378? The fundamental problem is that (i,a) in enumerate(A) is ambiguous: does i count entries of A, or is it an index for A? The name suggests it's a counter, and that's occasionally useful, but I'd wager that in practice it's more commonly used as an index for A. We can merge #16378, but I've never been thrilled with the name eachindexvalue, nor with having something so drattedly similar to enumerate. EDIT: or we could declare that enumerate, despite the implication of counting, actually returns an index.

@eschnett
Copy link
Contributor

For dictionaries, enumerate adds a one-based index. That is not really comparable to arrays since dictionaries iterate over (key,value) pairs by default, while arrays don't, but it indicates that enumerate uses one-based enumeration even if a key is present.

What about indexedvalues? Similar to enumerate, the prefix each is not really necessary, and adding an index could be called "indexing".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrays [a, r, r, a, y, s]
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants