Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for `..=` inclusive ranges (RFC #1192) -- originally `...` #28237
Comments
nikomatsakis
added
the
B-RFC-approved
label
Sep 4, 2015
This comment has been minimized.
This comment has been minimized.
JohanLarsson
commented
Oct 6, 2015
|
Maybe |
alexcrichton
added
the
T-lang
label
Feb 18, 2016
bors
added a commit
that referenced
this issue
Mar 5, 2016
bors
added a commit
that referenced
this issue
Mar 6, 2016
alexcrichton
added
B-unstable
T-libs
and removed
B-RFC-approved
labels
Mar 7, 2016
This comment has been minimized.
This comment has been minimized.
bakirov
commented
Mar 21, 2016
|
I think this will open up the way for the new kind of unpredictable errors in future because of a simple typo (.. vs ...). Better if it was .... (4 periods). This way it is less error-prone to the human factor, imo. |
This comment has been minimized.
This comment has been minimized.
|
I think rust-lang/rfcs#1592 and rust-lang/rfcs#1582 combined make a case for using the |
steveklabnik
referenced this issue
Jun 6, 2016
Closed
Unable to create a range to max value, e.g. `100..256` for a `Range<u8>` #23635
This comment has been minimized.
This comment has been minimized.
|
I've found this issue because I had off-by-one-dot error in my code when I've meant to use exclusive range.
The functionality is useful though, so I'd be happy to have it with a different syntax, e.g. |
This comment has been minimized.
This comment has been minimized.
andrewtj
commented
Jul 2, 2016
|
Is the syntax for this an open question? Since |
This comment has been minimized.
This comment has been minimized.
|
I'd personally prefer the |
This comment has been minimized.
This comment has been minimized.
|
I use inclusive ranges a lot for equivalent of C-like for loops The problem with overflow for inclusive ranges looks silly, but in practice I never ran into this problem, because Rust is annoying to use with any type other than Since this syntax is still feature-gated I hope the ship hasn't sailed. |
This comment has been minimized.
This comment has been minimized.
|
Considering that swift uses |
This comment has been minimized.
This comment has been minimized.
ottworks
commented
Jul 16, 2016
|
I don't have any useful insights, but I'd like for inclusive ranges to exit "experimental" status. As I was going through Rust By Example, I found one snippet that could benefit from this: fn fizzbuzz_to(n: u32) {
for n in 1..n + 1 {
fizzbuzz(n);
}
} |
This comment has been minimized.
This comment has been minimized.
|
Up ? |
LukasKalbertodt
referenced this issue
Jul 23, 2016
Merged
Temp. plant renderer and treegen fixes/improvements #52
This comment has been minimized.
This comment has been minimized.
|
I want to write an RFC for |
This comment has been minimized.
This comment has been minimized.
tengwar
commented
Aug 14, 2016
•
|
IMHO ..= looks weird. Swift's approach of ... and ..< looks better to me, because I prefer the ellipsis over two dots - ellipsis stands for omission and we are omitting the numbers between the start and the end of the range. I still think ... and .. was good enough. You have 1 character difference, so the mistake is harder to make than +/- or x/y or whatever. |
This comment has been minimized.
This comment has been minimized.
|
Since I misunderstood this myself earlier (and so deleted my comment): Per Rust's RFC process, this proposal has already been reviewed, discussed, and approved in RFC pull request 1192. The present issue tracks the implementation of what was previously decided there. The discussion covered many of the points people are raising here: alternative syntax (including no new syntax), the contrast with Ruby's similar operators, etc. If you feel strongly that the feature should be different, I think you need to take it through the same RFC process, because that's how changes to the language get made. But this issue isn't the place for that. |
This comment has been minimized.
This comment has been minimized.
|
@jimblandy maybe we should have @nikomatsakis edit that polite reminder and guidance into the first comment in Really Big Print. |
This comment has been minimized.
This comment has been minimized.
|
@shepmaster That would probably be a good thing to add to a template used to file all tracking issues. |
nrc
added
the
I-nominated
label
Aug 17, 2016
This comment has been minimized.
This comment has been minimized.
|
Nominating for discussion/possible FCP |
This comment has been minimized.
This comment has been minimized.
|
We discussed this in the @rust-lang/lang meeting. There was a general sense of unhappiness with this feature -- we considered moving to deprecate, but decided to hold off on that for the time being. There are two major objections to
To that end, we were wondering if someone would be willing to drive forward an RFC that enabled a more general syntax like that let people specify precisely whether the lower- and upper-bounds would be inclusive or exclusive. I think @aturon would be happy to work with someone on such an RFC. |
kumbayo
added a commit
to kumbayo/intellij-rust
that referenced
this issue
Mar 11, 2018
Undin
added a commit
to intellij-rust/intellij-rust
that referenced
this issue
Mar 11, 2018
kennytm
referenced this issue
Mar 14, 2018
Closed
Tracking issue for `start`, `end` and `new` methods of RangeInclusive #49022
bors
added a commit
that referenced
this issue
Mar 15, 2018
bors
added a commit
that referenced
this issue
Mar 15, 2018
alercah
added a commit
to alercah/book
that referenced
this issue
Mar 16, 2018
alercah
added a commit
to alercah/book
that referenced
this issue
Mar 16, 2018
This comment has been minimized.
This comment has been minimized.
mominul
commented
Mar 29, 2018
|
|
This comment has been minimized.
This comment has been minimized.
|
@mominul a feature is available only after it has been merged into master branch, thus |
This comment has been minimized.
This comment has been minimized.
|
That way you can test them on beta and nightly before they get pushed to stable. |
This comment has been minimized.
This comment has been minimized.
mominul
commented
Mar 29, 2018
|
Thanks for the inputs @kennytm and @clarcharr ! Rust 1.26 release is definitely not boring at least for me! |
This comment has been minimized.
This comment has been minimized.
ElectricCoffee
commented
Apr 1, 2018
|
I know it's too late to pitch in on this discussion, but why not omit the In Scala you have This both makes the intent more clear, and avoids the "off-by-one" error that everyone seems so concerned about. Granted, this does break all the existing code, if the original syntax doesn't stay supported. |
This comment has been minimized.
This comment has been minimized.
|
@ElectricCoffee in rust ranges support all types though, not just numbers. I think we'd need to introduce It works well in Scala, but Rust's design choices differ largely. |
This comment has been minimized.
This comment has been minimized.
|
@ElectricCoffee although l would like the feeling of that, I don't think it's desired to add the additional keywords for it. I believe built-in language keywords should be kept at a minimum, as they might collide with function or variable names. Although |
This comment has been minimized.
This comment has been minimized.
ElectricCoffee
commented
Apr 2, 2018
This comment has been minimized.
This comment has been minimized.
Boscop
commented
Apr 3, 2018
•
|
@ElectricCoffee But if |
This comment has been minimized.
This comment has been minimized.
ElectricCoffee
commented
Apr 3, 2018
|
And you're absolutely right about that @Boscop, it was however just an example of how words could be done. I believe I've seen In Scala, the inclusive range is more used than the exclusive one, and thus is given the shorter word. |
This comment has been minimized.
This comment has been minimized.
hyst329
commented
Apr 5, 2018
|
@timvisee One simply can use |
This comment has been minimized.
This comment has been minimized.
|
@hyst329 I didn't even think about that. I must say, I really like that idea! You are indeed correct. I don't believe though that this would be a proper full replacement for the current (/new) syntax. But it would be a nice addition. |
This comment has been minimized.
This comment has been minimized.
ssokolow
commented
Apr 5, 2018
|
I have to agree with Boscop's comment about intuitiveness. Aside from words like "including" and "except", day-to-day English doesn't really distinguish between inclusive and exclusive ranges strongly enough for there to be a ready-made shortcut. Unless it's used in a context where "A through B" is also used, it's ambiguous whether "A to B" means an inclusive or exclusive range in day-to-day speech here in southern Ontario, Canada, and "until" is associated with time strongly enough that, when used in this looser sense, it's unclear whether the "event" that "until" associates with is "until we see X" or "until we've processed X". |
This comment has been minimized.
This comment has been minimized.
|
@hyst329 Having them as methods would limit ranges to number types, though. I'd really rather not have one syntax for ranges of numbers and another for ranges of other things. I guess we could add a new catch-all trait to the prelude for creating ranges, but that's still verging on a breaking change for things which have actual |
This comment has been minimized.
This comment has been minimized.
|
I confess, I thought the suggestion of keywords was an April fools joke.
The ..= syntax has been stabilized.
…On Thu, Apr 5, 2018 at 1:53 PM, David Ross ***@***.***> wrote:
@hyst329 <https://github.com/hyst329> Having them as methods would limit
ranges to number types, though. I'd really rather not have one syntax for
ranges of numbers and another for ranges of other things.
I guess we could add a new catch-all trait to the prelude for creating
ranges, but that's still verging on a breaking change for things which have
actual to and until methods.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#28237 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAC3nwBj-b985q1Ez0OHDEHkG6DWV_5nks5tlloZgaJpZM4F4LbW>
.
|
This comment has been minimized.
This comment has been minimized.
|
Yeah, we've had 300+ comments on this issue, and the very first comment says:
I'm going to lock this issue for now, sorry if I'm stepping on any toes! |
rust-lang
locked as resolved and limited conversation to collaborators
Apr 5, 2018
Centril
added
disposition-merge
finished-final-comment-period
and removed
final-comment-period
labels
May 24, 2018
This comment has been minimized.
This comment has been minimized.
|
I believe that everything covered by this issue is done. Please reopen and update the checklist in the issue’s original message if there’s something else. |
nikomatsakis commentedSep 4, 2015
•
edited by kennytm
Current status
We are planning to to change the syntax for inclusive ranges and patterns to
..=. The...syntax in patterns is stable and will remain (silently) deprecated for the time being; rustfmt can rewrite...to..=. This comes after much discussion. See this comment for justification.No more syntax discussion should be had in this thread. Any different proposals of exclusive range syntax should take place on the user's forum or internals forum, after you have read all existing comments and their rationale here. Notably, breaking backwards compatibility is a non-starter.
Steps to take
..=as synonym for...in patterns and to accept..=in expressions #44709RangeInclusiveRangeInclusivehave been left out from this round of stabilization. Please track #49022 on this feature.