Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: .. in patterns #1492

Merged
merged 2 commits into from
May 13, 2016
Merged

RFC: .. in patterns #1492

merged 2 commits into from
May 13, 2016

Conversation

petrochenkov
Copy link
Contributor

Permit the .. pattern fragment in more contexts.

Rendered

@petrochenkov
Copy link
Contributor Author

cc rust-lang/rust#31443

[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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slice patterns are unstable (and buggy), and thus can easily be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

oli-obk commented Feb 8, 2016

Should S(a, b, ..) be allowed for struct S(A, B); ? For structs it currently is: http://is.gd/TsMz6N .

@petrochenkov
Copy link
Contributor Author

Should S(a, b, ..) be allowed for struct S(A, B); ?

Yes, .. means 0 or more subpatterns.

@nrc nrc added the T-lang Relevant to the language team, which will review and decide on the RFC. label Feb 8, 2016
@aturon aturon self-assigned this Feb 11, 2016
@nikomatsakis
Copy link
Contributor

This was pretty Always The Plan -- but we never did it because it involved work. I'm basically 👍 though I've not read the details of the RFC.

bors added a commit to rust-lang/rust that referenced this pull request Feb 17, 2016
And split `PatKind::Enum` into `PatKind::TupleStruct` and `PatKind::Path`.
This is the HIR part of #31581.
This is also kind of a preparation for rust-lang/rfcs#1492.

r? @eddyb
@petrochenkov
Copy link
Contributor Author

Implementation (without sub-list bindings): rust-lang/rust#32079

@nikomatsakis
Copy link
Contributor

Nominating for FCP.

@petrochenkov
Copy link
Contributor Author

I should probably strike out the sub-tuple bindings (a, b, c..) from this RFC given the discussion in #1582 and #376, at least for now.

@nikomatsakis
Copy link
Contributor

Hear ye, hear ye! This RFC is now entering final comment period.

@nikomatsakis
Copy link
Contributor

@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 nikomatsakis added final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. and removed I-nominated labels May 2, 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]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this binding mean?

A subslice pattern, see above - "The binding is not actually a binding, but one more pattern ..."

@nikomatsakis
Copy link
Contributor

I'd be (more) in favor of a variant of this that excludes all "bindings". In other words, allowing:

(pat*, .., pat*)
Foo(pat*, .., pat*)

and I'd probably prefer to exclude [] patterns which I think ought to be handled separately.

The binding forms introduce complicated semantics.

@petrochenkov
Copy link
Contributor Author

@nikomatsakis

I'd probably prefer to exclude [] patterns

This RFC doesn't propose any changes to slice patterns, it only uses them for analogy.

I'd be (more) in favor of a variant of this that excludes all "bindings".

With this I agree.

@nikomatsakis
Copy link
Contributor

@petrochenkov

This RFC doesn't propose any changes to slice patterns, it only uses them for analogy.

Huh. OK, I must have misread it. So much the better.

@brendanzab
Copy link
Member

I missed that subtlety too - maybe removing the slice examples might make it clearer?

@nikomatsakis
Copy link
Contributor

Huzzah! The @rust-lang/lang team has decided to accept this RFC. Specifically:

@nikomatsakis
Copy link
Contributor

Tracking issue: rust-lang/rust#33627

If you'd like to keep following the development of this feature, please subscribe to that issue, thanks! :)

@nikomatsakis nikomatsakis merged commit 4e9e843 into rust-lang:master May 13, 2016
@petrochenkov petrochenkov deleted the patdotdot branch September 21, 2016 20:28
critiqjo pushed a commit to critiqjo/rustdoc that referenced this pull request Dec 16, 2016
And split `PatKind::Enum` into `PatKind::TupleStruct` and `PatKind::Path`.
This is the HIR part of rust-lang/rust#31581.
This is also kind of a preparation for rust-lang/rfcs#1492.

r? @eddyb
@Centril Centril added A-syntax Syntax related proposals & ideas A-patterns Pattern matching related proposals & ideas A-data-types RFCs about data-types A-tuples Proposals relating to tuples. A-slice Slice related proposals & ideas labels Nov 23, 2018
@rust-lang rust-lang locked as spam and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-data-types RFCs about data-types A-patterns Pattern matching related proposals & ideas A-slice Slice related proposals & ideas A-syntax Syntax related proposals & ideas A-tuples Proposals relating to tuples. final-comment-period Will be merged/postponed/closed in ~10 calendar days unless new substational objections are raised. T-lang Relevant to the language team, which will review and decide on the RFC.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants