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 upRFC: `..` in patterns #1492
Conversation
petrochenkov
force-pushed the
petrochenkov:patdotdot
branch
from
cf5dc8c
to
2cd24ce
Feb 6, 2016
This comment has been minimized.
This comment has been minimized.
oli-obk
reviewed
Feb 8, 2016
| [unresolved]: #unresolved-questions | ||
|
|
||
| Sublist binding syntax conflicts with possible exclusive range patterns | ||
| `begin .. end`/`begin..`/`..end`. This problem already exists for slice patterns and has to be |
This comment has been minimized.
This comment has been minimized.
oli-obk
Feb 8, 2016
Contributor
Slice patterns are unstable (and buggy), and thus can easily be changed.
This comment has been minimized.
This comment has been minimized.
petrochenkov
Feb 8, 2016
Author
Contributor
Extensions proposed in this RFC are going to be unstable too and are supposed to be changed together with slice patterns if changed at all.
oli-obk
reviewed
Feb 8, 2016
| S(subpat1, .., subpatN) | ||
| // **NEW**: Tuple struct patterns, any position with a sublist binding. | ||
| // The binding has a tuple type. | ||
| S(subpat1, binding.., subpatN) |
This comment has been minimized.
This comment has been minimized.
oli-obk
Feb 8, 2016
Contributor
these are somewhat problematic. Afaik there's no guarantee that (B, C) has the same memory layout as the last two parts of (A, B, C), so taking a slice into a tuple might not be so trivial.
This comment has been minimized.
This comment has been minimized.
petrochenkov
Feb 8, 2016
Author
Contributor
Hmm, this is an interesting observation.
It means that at least by ref bindings have to be restricted.
I'll update the RFC.
This comment has been minimized.
This comment has been minimized.
|
Should |
This comment has been minimized.
This comment has been minimized.
Yes, |
nrc
added
the
T-lang
label
Feb 8, 2016
aturon
self-assigned this
Feb 11, 2016
This comment has been minimized.
This comment has been minimized.
|
This was pretty Always The Plan -- but we never did it because it involved work. I'm basically |
petrochenkov
referenced this pull request
Feb 15, 2016
Merged
refactoring: Rename hir::Pat_ and its variants #31685
bors
added a commit
to rust-lang/rust
that referenced
this pull request
Feb 17, 2016
bors
added a commit
to rust-lang/rust
that referenced
this pull request
Feb 17, 2016
petrochenkov
referenced this pull request
Mar 6, 2016
Closed
[RFC] Implement `..` in tuple (struct) patterns #32079
This comment has been minimized.
This comment has been minimized.
|
Implementation (without sub-list bindings): rust-lang/rust#32079 |
This comment has been minimized.
This comment has been minimized.
|
Nominating for FCP. |
nikomatsakis
added
the
I-nominated
label
Apr 12, 2016
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Hear ye, hear ye! This RFC is now entering final comment period. |
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov very well... to be honest I've not read this closely, though I'm in favor of the spirit. We had decided to put this into FCP, but would you rather we wait? (We can keep your proposed edit in mind, I imagine.) |
nikomatsakis
added
final-comment-period
and removed
I-nominated
labels
May 2, 2016
nikomatsakis
reviewed
May 12, 2016
| [subpat1, .., subpatN] | ||
| // Slice patterns, any of the above with a subslice binding. | ||
| // By ref bindings are allowed, slices and subslices always have compatible layouts. | ||
| [subpat1, binding.., subpatN] |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
May 12, 2016
Contributor
What does this binding mean? This feels like it overlaps with slice patterns, which (I think) still require some further RFC to "complete"? I can't remember if we postponed that work or not. :)
This comment has been minimized.
This comment has been minimized.
petrochenkov
May 12, 2016
Author
Contributor
What does this binding mean?
A subslice pattern, see above - "The binding is not actually a binding, but one more pattern ..."
This comment has been minimized.
This comment has been minimized.
|
I'd be (more) in favor of a variant of this that excludes all "bindings". In other words, allowing:
and I'd probably prefer to exclude The binding forms introduce complicated semantics. |
This comment has been minimized.
This comment has been minimized.
This RFC doesn't propose any changes to slice patterns, it only uses them for analogy.
With this I agree. |
This comment has been minimized.
This comment has been minimized.
Huh. OK, I must have misread it. So much the better. |
This comment has been minimized.
This comment has been minimized.
|
I missed that subtlety too - maybe removing the slice examples might make it clearer? |
This comment has been minimized.
This comment has been minimized.
|
Huzzah! The @rust-lang/lang team has decided to accept this RFC. Specifically:
|
nikomatsakis
referenced this pull request
May 13, 2016
Closed
`..` in tuple-like patterns (tracking issue for RFC 1492) #33627
This comment has been minimized.
This comment has been minimized.
|
Tracking issue: rust-lang/rust#33627 If you'd like to keep following the development of this feature, please subscribe to that issue, thanks! :) |
petrochenkov commentedFeb 6, 2016
Permit the
..pattern fragment in more contexts.Rendered