{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/959","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/959/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/959/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/959/events","html_url":"https://github.com/dotnet/roslyn/issues/959","id":59413486,"number":959,"title":"[Proposal] make 'switch' more real-life usable","user":{"login":"XuTpuK","id":1545616,"avatar_url":"https://avatars.githubusercontent.com/u/1545616?v=3","gravatar_id":"","url":"https://api.github.com/users/XuTpuK","html_url":"https://github.com/XuTpuK","followers_url":"https://api.github.com/users/XuTpuK/followers","following_url":"https://api.github.com/users/XuTpuK/following{/other_user}","gists_url":"https://api.github.com/users/XuTpuK/gists{/gist_id}","starred_url":"https://api.github.com/users/XuTpuK/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XuTpuK/subscriptions","organizations_url":"https://api.github.com/users/XuTpuK/orgs","repos_url":"https://api.github.com/users/XuTpuK/repos","events_url":"https://api.github.com/users/XuTpuK/events{/privacy}","received_events_url":"https://api.github.com/users/XuTpuK/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/Question","name":"Question","color":"fc2929"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":23,"created_at":"2015-03-01T19:32:44Z","updated_at":"2015-03-03T21:47:45Z","closed_at":"2015-03-03T21:47:45Z","body":"'switch' operator was blindly copied from C/Java, but 1) by some strange reason lost ability to fall from one branch to another 2) still unusable like in original languages\r\n\r\nWhat is \"nature\" of 'switch'? SWITCH code branches, running exactly one of 'em! So if I declare branch \"case 1: do_that\", why the hell I should worry about all that \"break\"s, \"fall through\" and so on?!\r\n\r\nSwitch should BE the switch:\r\n\r\n    switch(a) {\r\n    case 1: action1(); action2(); goto case default;\r\n    case 2: { int z = a; }// local scope\r\n    default: z = 4;\r\n    }\r\n\r\nThat's it!  Why we like monkeys still repeat invention of 70-th \"case 1: .... break;\" if we even cannot fall through?! Good question to designers of C#!"},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/77043389","html_url":"https://github.com/dotnet/roslyn/issues/959#issuecomment-77043389","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/959","id":77043389,"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},"created_at":"2015-03-03T21:47:45Z","updated_at":"2015-03-03T21:47:45Z","body":"While the design of the `switch` statement may leave much to be desired, it is already in the C# language and familiar to many programmers. Falling through from one case to another is often error-prone, so we disallow it. However, we allow the simple case of fall-through where there are no statements between one case label and the next.\r\n\r\nIf we were to change the language to say that there is an implicit `break` after any statements following a case label, that would be a breaking change in the usual case that there is more than one case label in a row. Since we do not want to make breaking changes, we do not want to make the break statement implicit. It would be too subtle to have very different runtime behavior when there are no statements versus there being a single \"empty\" statement `;`.\r\n\r\nHaving said that, we are considering an alternative switch construct for use with the pattern-matching proposal. The main motivation would be to provide an expression form. Since it would be a distinct syntactic form, we are not constrained by the sensibilities (or otherwise) of the existing switch statement.\r\n\r\nThanks for the question. I hope we've answered it to your satisfaction."}}