{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/16","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/16/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/16/events","html_url":"https://github.com/Microsoft/TypeScript/issues/16","id":37906351,"number":16,"title":"Suggestion: \"safe navigation operator\", i.e. x?.y","user":{"login":"RyanCavanaugh","id":6685088,"avatar_url":"https://avatars.githubusercontent.com/u/6685088?v=3","gravatar_id":"","url":"https://api.github.com/users/RyanCavanaugh","html_url":"https://github.com/RyanCavanaugh","followers_url":"https://api.github.com/users/RyanCavanaugh/followers","following_url":"https://api.github.com/users/RyanCavanaugh/following{/other_user}","gists_url":"https://api.github.com/users/RyanCavanaugh/gists{/gist_id}","starred_url":"https://api.github.com/users/RyanCavanaugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RyanCavanaugh/subscriptions","organizations_url":"https://api.github.com/users/RyanCavanaugh/orgs","repos_url":"https://api.github.com/users/RyanCavanaugh/repos","events_url":"https://api.github.com/users/RyanCavanaugh/events{/privacy}","received_events_url":"https://api.github.com/users/RyanCavanaugh/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Needs%20Proposal","name":"Needs Proposal","color":"556b75"},{"url":"https://api.github.com/repos/Microsoft/TypeScript/labels/Suggestion","name":"Suggestion","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":41,"created_at":"2014-07-15T17:27:00Z","updated_at":"2015-08-19T07:18:55Z","closed_at":null,"body":"C# and other languages have syntax sugar for accessing property chains where `null` (or in our case, `undefined`) might be encountered at any point in the object hierarchy.\r\n\r\n```TypeScript\r\nvar x = { y: { z: null, q: undefined } };\r\nconsole.log(x?.y?.z?.foo); // Should print 'null'\r\nconsole.log(x?.baz); // Still an error\r\nconsole.log(x.y.q?.bar); // Should print 'undefined'\r\n```\r\n\r\nNeed proposal on what exactly we should codegen, keeping in mind side effects of accessors."},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/132471981","html_url":"https://github.com/Microsoft/TypeScript/issues/16#issuecomment-132471981","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/16","id":132471981,"user":{"login":"DanielRosenwasser","id":972891,"avatar_url":"https://avatars.githubusercontent.com/u/972891?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielRosenwasser","html_url":"https://github.com/DanielRosenwasser","followers_url":"https://api.github.com/users/DanielRosenwasser/followers","following_url":"https://api.github.com/users/DanielRosenwasser/following{/other_user}","gists_url":"https://api.github.com/users/DanielRosenwasser/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielRosenwasser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielRosenwasser/subscriptions","organizations_url":"https://api.github.com/users/DanielRosenwasser/orgs","repos_url":"https://api.github.com/users/DanielRosenwasser/repos","events_url":"https://api.github.com/users/DanielRosenwasser/events{/privacy}","received_events_url":"https://api.github.com/users/DanielRosenwasser/received_events","type":"User","site_admin":false},"created_at":"2015-08-19T07:18:55Z","updated_at":"2015-08-19T07:18:55Z","body":"@basarat, my understanding of what @BrendanEich said (and he can correct me if I'm wrong - sorry for the ping!) is *not* that `?.` is right-associative, but that CoffeeScript special cases property accesses on the right of the `?.` to be right-associative. For example, it will parse\r\n\r\n```CoffeeScript\r\no.p?.q.r.s\r\n```\r\n\r\nas\r\n\r\n```CoffeeScript\r\n((o . p) ?. (q.(r.s))) # or something close to this\r\n```\r\n\r\ninstead of\r\n\r\n```CoffeeScript\r\n((((o . p) ?. q) . r) . s)\r\n```\r\n\r\nbecause it's easier to emit.\r\n\r\nOur AST needs to lend well to sane semantic analysis, so our emitting procedure can afford to be slightly more complex to suit this need."}}