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

Please allow mix declarations and expressions on tuple deconstruction #1382

Closed
Thaina opened this issue Mar 15, 2018 · 4 comments
Closed

Please allow mix declarations and expressions on tuple deconstruction #1382

Thaina opened this issue Mar 15, 2018 · 4 comments

Comments

@Thaina
Copy link

Thaina commented Mar 15, 2018

var x = 0;
(var y,var z) = (0,0);

(var w,x) = (0,0); // ERROR : A deconstruction cannot mix declarations and expressions

Are there any thing that make this syntax cannot be possible?

@jnm2
Copy link
Contributor

jnm2 commented Mar 15, 2018

From https://github.com/dotnet/csharplang/issues/365:

This reformulation of deconstruction allows us to remove from the syntax model the new statement form for a deconstruction declaration. It also allows us to generalize what we allow in the future:

int x;
(x, int y) = e;

Here, the left-hand-side contains a mixture of already-existing variables (in this case x) and newly declared variables (int y). And it can be used in an expression context as well (e.g. as the body of an expression-bodied method).

@Thaina
Copy link
Author

Thaina commented Mar 15, 2018

Thanks

@Thaina Thaina closed this as completed Mar 15, 2018
@jnm2
Copy link
Contributor

jnm2 commented Mar 15, 2018

I'm not aware of any outstanding request for this though, so if you want it to happen you might need to reopen.

@Thaina Thaina reopened this Mar 15, 2018
@gafter
Copy link
Member

gafter commented Mar 15, 2018

Dup of #125

@gafter gafter closed this as completed Mar 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants