{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/6183","labels_url":"https://api.github.com/repos/dotnet/roslyn/issues/6183/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/roslyn/issues/6183/comments","events_url":"https://api.github.com/repos/dotnet/roslyn/issues/6183/events","html_url":"https://github.com/dotnet/roslyn/issues/6183","id":112444581,"number":6183,"title":"Proposal: out var declaration","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":59,"closed_issues":10,"state":"open","created_at":"2015-02-02T23:41:34Z","updated_at":"2015-10-20T19:38:27Z","due_on":null,"closed_at":null},"comments":7,"created_at":"2015-10-20T19:38:27Z","updated_at":"2015-10-20T22:18:20Z","closed_at":null,"body":"I propose to allow a variable be declared at the same time that is it passed as an out parameter:\r\n\r\n> *argument-value*:\r\n> &nbsp;&nbsp;&nbsp;&nbsp;`out` *type* *identifier*\r\n\r\nA variable declared this way is read-only and scoped to the enclosing statement. More specifically, the scope will be the same as for a *pattern-variable* introduced via pattern-matching.\r\n\r\nYou should be able to use the contextual keyword `var` for the variable's type, in which case the specification for overload resolution would have to be modified to account for that possibility."},"comment":{"url":"https://api.github.com/repos/dotnet/roslyn/issues/comments/149718805","html_url":"https://github.com/dotnet/roslyn/issues/6183#issuecomment-149718805","issue_url":"https://api.github.com/repos/dotnet/roslyn/issues/6183","id":149718805,"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-10-20T22:18:19Z","updated_at":"2015-10-20T22:18:19Z","body":"@bbarry Not quite. The variable will be scoped to the \"then\" clause only (not the \"else\" clause) because that's the way pattern variables work. But correct: \"out variables\" in a local variable initializer do not escape to the enclosing scope. If you want it in the enclosing scope you know where to declare it.\r\n\r\n@orthoxerox We do no intend to revisit every existing API that uses out parameters, change the recommendation for designing APIs, nor deprecate out parameters\r\n\r\n@vladd You did not declare `r` as having any special relation to a method invocation. It is an ordinary local variable placed into the enclosing scope. `n`, on the other hand, is defined by reference to the method invocation and is *not* placed into the enclosing scope. If you want it mutable and in the enclosing scope, you know where to declare it."}}