Repository navigation
Make List.{take,drop} total - #14124
Conversation
@Octachron: do you validate? |
|
If we agree that this PR specification is the right one, then this is a specification bugfix and should be cherry-picked to 5.4. |
OK, thanks. I am of the opinion that this is a specification bugfix, as is @gasche. |
6577585 to
6778e39
Compare
gasche
left a comment
There was a problem hiding this comment.
I agree, and I believe this is worth having in 5.4 to minimize the non-totality version interval.
|
CI failure is unrelated. Merging. |
(cherry picked from commit 6b59d66)
|
Cherry-pick to 5.4: da2b221 |
|
Thanks all! |
|
(Late comment, I was looking at the changelog for 5.4 beta) This specific exception caught a bug in my code yesterday. Specifically, I had an overflow turn my count into a negative value, and then it was passed to
Note also that other languages do tend to prevent negative counts there, e.g. Java raises an exception, Rust prevents the problem by receiving an unsigned integer, Python's itertool raises an exception etc.. I don't necessarily disagree with this PR, I don't think there's necessarily a "best" answer here, but I thought I'd flag it for future similar discussions. |
|
Personally I also don't have a strong opinion here, I think both view have their own merits. I do however find totality easier for lazy (in the human sense) edge case reasoning – i.e. rather than proving that As mentioned here the reason why I wanted to do this change is that I'm contemplating adding corresponding functionality to the |
|
Agreed. An option would be to add some alternative function that is already defensive (e.g. |
See discussion.
Raising is highly non-standard across languages and libraries and the functions have only been there in 5.3 so far.
I think this should go in 5.4 too.