Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Champion "deconstruction in from and let" #189

Closed
1 of 5 tasks
gafter opened this issue Feb 26, 2017 · 7 comments
Closed
1 of 5 tasks

Champion "deconstruction in from and let" #189

gafter opened this issue Feb 26, 2017 · 7 comments
Assignees
Labels
Needs Approved Specification This issue needs an LDM-approved specification Proposal champion Smallish Feature
Milestone

Comments

@gafter
Copy link
Member

gafter commented Feb 26, 2017

Summary

Allow declaring multiple range at once with let. For example, ... let (x, y) = deconstructable ....

  • Proposal added
  • Discussed in LDM
  • Decision in LDM
  • Finalized (done, rejected, inactive)
  • Spec'ed

See also dotnet/roslyn#13964

https://github.com/dotnet/csharplang/blob/master/meetings/2016/LDM-2016-12-07-14.md#deconstruction

@gafter gafter added this to the 7.X candidate milestone Feb 26, 2017
@MadsTorgersen MadsTorgersen modified the milestones: 7.X candidate, 7.3 candidate, 8.X candidate Oct 25, 2017
@gafter gafter modified the milestones: 8.X candidate, Any Time Apr 29, 2019
@333fred 333fred added the Needs Approved Specification This issue needs an LDM-approved specification label Oct 15, 2020
@jhgbrt
Copy link

jhgbrt commented Dec 14, 2021

Is there any progress on this? The more one gets used to deconstruction, the more annoying it becomes that from and let clauses in LINQ queries don't support this :-)

@333fred
Copy link
Member

333fred commented Dec 14, 2021

Is there any progress on this?

This feature is in the Any Time bucket, which means we are unlikely to spend time on it ourselves, but if a motivated community member would like to contribute, we would be happy to review. Currently, this issue needs a specification for LDM to review and approve.

@jhgbrt
Copy link

jhgbrt commented Dec 6, 2022

Any chance this could make it in C# 12?

@CyrusNajmabadi
Copy link
Member

@jhgbrt see the comment above yours.

@sab39
Copy link

sab39 commented Dec 7, 2022

Does this cover things like

from person in People
where person.Age is int age && age >= 18 // person.Age is a nullable int
select (person, age)

or would that be a separate ticket?

@333fred
Copy link
Member

333fred commented Dec 7, 2022

I don't think that would be covered by this. That would be changing the scoping of existing code, which would be concerning.

@sab39
Copy link

sab39 commented Dec 7, 2022

Oof. I see what you mean - my code example would compile today if something called age existed in an outer scope. That seems to me like a footgun in the status quo, though: if someone declares a variable in a pattern expression in a where clause and then uses the same identifier in the next line in a select clause, it's unlikely that they intended to pull in a different value from outside, and even more unlikely that someone reading the code would recognize what's happening.

Of course, breaking existing code is a big deal and should only be done in extenuating circumstances. But does "the code is probably not doing what they intended in the first place" count as an extenuating circumstance?

@jcouv jcouv moved this to Language/design in Compiler: Julien's umbrellas Jun 3, 2024
@dotnet dotnet locked and limited conversation to collaborators Nov 19, 2024
@MadsTorgersen MadsTorgersen converted this issue into discussion #8874 Dec 12, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Needs Approved Specification This issue needs an LDM-approved specification Proposal champion Smallish Feature
Projects
Archived in project
Development

No branches or pull requests

7 participants