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

[Tuple Specification] numerous additions needed for discards and deconstruction #3197

Closed
BillWagner opened this issue Feb 12, 2020 · 2 comments
Labels
standard proposal Issues or PRs related to creating standard updates from feature specifications.

Comments

@BillWagner
Copy link
Member

The description of deconstruction is not complete:

  1. The grammar production needs to express both initialization and assignment on the LHS of a deconstruction.
  2. The RHS of a deconstruction could be any type that supports deconstruction (tuple or any type with a candidate accessible Deconstruct method.) That isn't specified in the grammar.
  3. The scope and definite assignment state of the destination of a deconstruction must be specified.
  4. Can deconstruction be a compound assignment? (Stated another way, what is the type of a deconstruction assignment expression?
  5. The example that shows a Deconstruct method needs to be replaced by specification language for the rules of a Deconstruct method.

Deconstruction is mentioned in the same breath as assignment. If deconstruction can only occur on the LHS of a (simple?, compound?) assignment, should deconstruction be covered under assignment rather than in its own section? If the two are in separate sections, the expression grammar needs to have the new production, tuple_deconstruction_expression, plugged into it. Support for tuple deconstruction could be the beginning of a more general pattern support mechanism to come later. If that is the case, perhaps we should admit that and start using pattern-related terminology and organization. If so, that suggests tuple deconstruction should be separate from the assignment operator, in a (pre-)patterns section that will be expanded over future spec versions.

@BillWagner BillWagner added the standard proposal Issues or PRs related to creating standard updates from feature specifications. label Feb 12, 2020
@michael-hawker
Copy link

michael-hawker commented May 3, 2022

Related to #1358?

I believe this is what would be needed for the is pattern to work, right?

i.e. I have this currently:

var info = e.Parameter as (IEnumerable<ToolkitSampleMetadata> Samples, IEnumerable<ToolkitFrontMatter> Docs, bool AreDocsFirst)?;

if (info is not null)
{

But would rather have:

if (e.Parameter is (IEnumerable<ToolkitSampleMetadata> Samples, IEnumerable<ToolkitFrontMatter> Docs, bool AreDocsFirst) info)
{

Instead today I get CS1061 and CS8129 errors about Deconstruct missing:

image

@BillWagner
Copy link
Member Author

This has been added in the C# 7 standard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
standard proposal Issues or PRs related to creating standard updates from feature specifications.
Projects
None yet
Development

No branches or pull requests

2 participants