{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/6400","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/6400/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/6400/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/6400/events","html_url":"https://github.com/dotnet/roslyn/issues/6400","id":113917694,"number":6400,"title":"Proposal: Destructuring (assignment?) statement","user":{"login":"gafter","id":3804346,"avatar_url":"https://avatars.githubusercontent.com/u/3804346?v=3","gravatar_id":"","url":"https://api.github.com/users/gafter","html_url":"https://github.com/gafter","followers_url":"https://api.github.com/users/gafter/followers","following_url":"https://api.github.com/users/gafter/following{/other_user}","gists_url":"https://api.github.com/users/gafter/gists{/gist_id}","starred_url":"https://api.github.com/users/gafter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gafter/subscriptions","organizations_url":"https://api.github.com/users/gafter/orgs","repos_url":"https://api.github.com/users/gafter/repos","events_url":"https://api.github.com/users/gafter/events{/privacy}","received_events_url":"https://api.github.com/users/gafter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Area-Language%20Design","name":"Area-Language Design","color":"5319e7"},{"url":"https://api.github.com/repos/dotnet/roslyn/labels/Feature%20Request","name":"Feature Request","color":"fc2929"}],"state":"open","locked":false,"assignee":{"login":"gafter","id":3804346,"avatar_url":"https://avatars.githubusercontent.com/u/3804346?v=3","gravatar_id":"","url":"https://api.github.com/users/gafter","html_url":"https://github.com/gafter","followers_url":"https://api.github.com/users/gafter/followers","following_url":"https://api.github.com/users/gafter/following{/other_user}","gists_url":"https://api.github.com/users/gafter/gists{/gist_id}","starred_url":"https://api.github.com/users/gafter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gafter/subscriptions","organizations_url":"https://api.github.com/users/gafter/orgs","repos_url":"https://api.github.com/users/gafter/repos","events_url":"https://api.github.com/users/gafter/events{/privacy}","received_events_url":"https://api.github.com/users/gafter/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/dotnet/roslyn/milestones/8","html_url":"https://github.com/dotnet/roslyn/milestones/C%23%207%20and%20VB%2015","labels_url":"https://api.github.com/repos/dotnet/roslyn/milestones/8/labels","id":962632,"number":8,"title":"C# 7 and VB 15","description":"\r\n\r\n<!---\r\n@huboard:{\"order\":0.375}\r\n-->\r\n","creator":{"login":"gafter","id":3804346,"avatar_url":"https://avatars.githubusercontent.com/u/3804346?v=3","gravatar_id":"","url":"https://api.github.com/users/gafter","html_url":"https://github.com/gafter","followers_url":"https://api.github.com/users/gafter/followers","following_url":"https://api.github.com/users/gafter/following{/other_user}","gists_url":"https://api.github.com/users/gafter/gists{/gist_id}","starred_url":"https://api.github.com/users/gafter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gafter/subscriptions","organizations_url":"https://api.github.com/users/gafter/orgs","repos_url":"https://api.github.com/users/gafter/repos","events_url":"https://api.github.com/users/gafter/events{/privacy}","received_events_url":"https://api.github.com/users/gafter/received_events","type":"User","site_admin":false},"open_issues":61,"closed_issues":10,"state":"open","created_at":"2015-02-02T23:41:34Z","updated_at":"2015-10-28T20:42:29Z","due_on":null,"closed_at":null},"comments":42,"created_at":"2015-10-28T20:42:20Z","updated_at":"2015-10-29T16:47:26Z","closed_at":null,"body":"Inspired by an [F# feature](https://msdn.microsoft.com/en-us/library/dd233238.aspx) and a [conversation on another issue](https://github.com/dotnet/roslyn/issues/5154#issuecomment-151974994), we could support tuple decomposition like this:\r\n\r\n> *block-statement:*\r\n&nbsp;&nbsp;&nbsp;&nbsp;*let-statement*\r\n*let-statement:*\r\n&nbsp;&nbsp;&nbsp;&nbsp;`let` *pattern* `=` *expression* `;`\r\n\r\n`let` is a new keyword (or perhaps contextual keyword).\r\n\r\nSemantically, it is an error if the compiler cannot prove that the expression always matches the pattern. Any pattern variables in the *pattern* are in scope throughout the enclosing block and are definitely assigned (only) after the execution of the *let-statement* completes.\r\n\r\nThis would apply to tuples as follows. Given\r\n\r\n```cs\r\npublic (int, int) ComputePoint() => …\r\n```\r\n\r\nYou could receive the results into a block scope thusly\r\n\r\n```cs\r\n\tlet (int x, int y) = ComputePoint();\r\n```\r\n\r\nA side-effect of this proposal is that it gives you a way to declare read-only locals (pattern variables are currently proposed to be readonly):\r\n\r\n```cs\r\n\tlet var x = expression;\r\n```\r\n\r\nWe could add an identifier-only version as F# does as well:\r\n\r\n```cs\r\n\tlet x = expression;\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/152245246","html_url":"https://github.com/dotnet/roslyn/issues/6400#issuecomment-152245246","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/6400","id":152245246,"user":{"login":"alrz","id":3105979,"avatar_url":"https://avatars.githubusercontent.com/u/3105979?v=3","gravatar_id":"","url":"https://api.github.com/users/alrz","html_url":"https://github.com/alrz","followers_url":"https://api.github.com/users/alrz/followers","following_url":"https://api.github.com/users/alrz/following{/other_user}","gists_url":"https://api.github.com/users/alrz/gists{/gist_id}","starred_url":"https://api.github.com/users/alrz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alrz/subscriptions","organizations_url":"https://api.github.com/users/alrz/orgs","repos_url":"https://api.github.com/users/alrz/repos","events_url":"https://api.github.com/users/alrz/events{/privacy}","received_events_url":"https://api.github.com/users/alrz/received_events","type":"User","site_admin":false},"created_at":"2015-10-29T16:47:26Z","updated_at":"2015-10-29T16:47:26Z","body":"@gafter From #5757 \r\n\r\n>```\r\nFoo foo = ...; // has a conversion to int\r\nswitch (foo)\r\n{\r\n    case 1: // uses the converted value\r\n    case Foo(2): // uses the original value\r\n    case 3: // uses the converted value\r\n}\r\n```\r\n\r\nBut the fact that the conversation will be considered per `case` (not once) might be the source of the problem in my example. I thought, since all the cases should be *pattern compatible* with the target object, hence they are compatible with each other, meaning that they target a single type (in this case `P`) and the conversation should apply once. Actually in F#, type of the target object **inferred** by cases in match `let n = match n with Even -> ... | Odd -> ... // n is int` and the active pattern function (which simulated by an implicit conversation in my example) will be executed once."}}