Fix Issue 15720 - iota(long.max, long.min, step) does not work properly#5397
Fix Issue 15720 - iota(long.max, long.min, step) does not work properly#5397dlang-bot merged 1 commit intodlang:masterfrom
Conversation
|
std/range/package.d
Outdated
| auto t1 = iota(0, 10, 2); | ||
| auto t2 = iota(1, 1, 0); | ||
| //float overloads use std.conv.to so can't be @nogc or nothrow | ||
| alias ssize_t = Unsigned!size_t; |
There was a problem hiding this comment.
Wait, wasn't this supposed to say Signed!size_t?
There was a problem hiding this comment.
Can't believe I messed that up! brb
There was a problem hiding this comment.
no failure... "everything turned out better than expected"
|
Issue 15720 says the expected output is: With this PR, the test case in 15720 prints: The second number is off by one. Which one is correct? |
|
My reasoning went as follows. For simplicity, let's reduce the matter to 1-nibble numbers. So then we have iota(7, -8, -2) and the question is whether there are an odd (8) or an even (7) count in there. So we have 7, 5, 3, 1, -1, -3, -5, -7 so 8 numbers total. |
|
Same result here. |
| // iota | ||
| /** | ||
| Construct a range of values that span the given starting and stopping | ||
| Creates a range of values that span the given starting and stopping |
There was a problem hiding this comment.
I'm not complaining, but why the change from "construct" to "creates"?
There was a problem hiding this comment.
"This guy construct" -> no predicate. "This guy constructs" -> good. "This guy creates" -> even better.
There was a problem hiding this comment.
"This guy allows you to construct"
But Occam's Razor tells me that "creates" is probably better.
There was a problem hiding this comment.
As I'm almost as interested in natural languages as I am in programming languages, I was interested in seeing if there was any correct answer. Congrats, you piqued my curiosity ;-)
Practically reopening #5396