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 upAllow multiple (fixed-size) subslices borrows in one pattern #101
Conversation
krdln
added some commits
Jun 1, 2014
This comment has been minimized.
This comment has been minimized.
|
+1, I was going to propose the same thing. If we allow runtime values for the lengths of the subslices, and add support for multiple (I'm not entirely sold on the syntax, but I think your idea is better than anything I came up with.) |
This comment has been minimized.
This comment has been minimized.
|
cc @jakub- |
This comment has been minimized.
This comment has been minimized.
ghost
commented
Jun 27, 2014
|
-1. I think I'd actually be in favour of removing them altogether or reducing them to only the simplest cases ([a, b, c, ..tail]). |
This comment has been minimized.
This comment has been minimized.
ghost
commented
Jun 27, 2014
|
To elaborate, they're making the pattern sanity check pass much more complicated than it really needs to be and add significant disconnect between that pass and the codegen for patterns. I think I'd also agree they also don't fit well with the other patterns that only cover ADTs, which vectors are not. |
glaebhoerl
referenced this pull request
Jun 28, 2014
Closed
Remove variable-length slice patterns from the language #144
This comment has been minimized.
This comment has been minimized.
|
Is it even possible to check exhaustiveness and redundancy of these kinds of patterns? |
This comment has been minimized.
This comment has been minimized.
|
I think it would have to be conservative, i.e. if the compiler can't prove exhaustiveness, require a wildcard pattern. |
This comment has been minimized.
This comment has been minimized.
|
@zwarich |
This comment has been minimized.
This comment has been minimized.
|
Sorry, I totally missed the fixed-size qualification. |
This comment has been minimized.
This comment has been minimized.
|
It depends on whether you allow the fixed sizes to be runtime values. If you do, my answer applies. If you don't, @krdln's does. I think. Edit: Hm, I see now that runtime values for the fixed sizes was never mentioned in the OP. Mea culpa. I misinterpreted the unresolved question section. |
This comment has been minimized.
This comment has been minimized.
FWIW, I think this syntax change makes some logical sense on its own terms. We currently use the syntax And then as a side benefit, it becomes possible to have both of them where the cases overlap, as with the fixed-length slice patterns in this proposal. |
This comment has been minimized.
This comment has been minimized.
|
+1 I like this. At the very least, I think we should change |
This comment has been minimized.
This comment has been minimized.
|
This was discussed at this week's Rust meeting (https://github.com/rust-lang/meeting-minutes/blob/master/weekly-meetings/2014-08-12.md). We decided that we don't want to implement these changes in full, in particular that enhancing slice matching is something we are a little bit uncomfortable with and needs some thought and planning but is low enough priority that we don't want to do that before 1.0. However, we are sympathetic to leaving this option open in the future, so we would like to make the change to slice syntax (the position of Thanks for the RFC! |
This comment has been minimized.
This comment has been minimized.
|
I'm happy to hear that there's a slight possibility that my RFC might be accepted in a far future! Edit: Here it is: #202 |
krdln commentedJun 1, 2014
Change syntax in slice pattern matching from
..xstoxs..(eg.[head, tail..]),and allow multiple (fixed-size) subslices borrows in one pattern (eg.
[xs..3, ys..3]).