Changed zip and lockstep of std.range to assert same length#5917
Changed zip and lockstep of std.range to assert same length#5917dukc wants to merge 1 commit intodlang:masterfrom
Conversation
|
Thanks for your pull request, @dukc! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Some tips to help speed things up:
Bear in mind that large or tricky changes may require multiple rounds of review and revision. Please see CONTRIBUTING.md for more information. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
MetaLang
left a comment
There was a problem hiding this comment.
There's no way we can change this; it's very likely that there's client code out there that depends on zip/lockstep throwing an exception; therefore, it's wrapped in a try-catch that catches Exception. Changing this to throw an Error on length mismatch means that code will still compile but will now crash at runtime.
|
Such code is doubtlessly bug-prone anyway since the length property does not check for all ranges, resulting in overflow sooner or later. But that makes the code no less existent... |
|
I can tell you from experience that Andrei will reject this due to its breaking nature, and I'd have to agree with him. I would refactor this to add a new |
|
Good idea, I think. Does not let us infer Already 3 to be considered against. Enough to convince me off. |
|
FWIW DIP1008 has been merged two days ago. So while you might not get |
…instead of enforcing. This is of course controversal since it's breaking but I decided it's worth a discussion. Isn't it after all clearly a bug if zipped ranges with
StoppingPolicy.RequireSameLengthhave different lengths?I made the same change for enforcement of
!stoppingPolicy != StoppingPolicy.LongestforLockStepand enforcement of default-initializable elemets.The advantages are that functions can be faster in production code and, in case of
zip,nothrowcan be inferred.