{"action":"created","issue":{"url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4091","labels_url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4091/labels{/name}","comments_url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4091/comments","events_url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4091/events","html_url":"https://github.com/jashkenas/coffeescript/issues/4091","id":106067493,"number":4091,"title":"Existential Splat","user":{"login":"olleicua","id":1270102,"avatar_url":"https://avatars.githubusercontent.com/u/1270102?v=3","gravatar_id":"","url":"https://api.github.com/users/olleicua","html_url":"https://github.com/olleicua","followers_url":"https://api.github.com/users/olleicua/followers","following_url":"https://api.github.com/users/olleicua/following{/other_user}","gists_url":"https://api.github.com/users/olleicua/gists{/gist_id}","starred_url":"https://api.github.com/users/olleicua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olleicua/subscriptions","organizations_url":"https://api.github.com/users/olleicua/orgs","repos_url":"https://api.github.com/users/olleicua/repos","events_url":"https://api.github.com/users/olleicua/events{/privacy}","received_events_url":"https://api.github.com/users/olleicua/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jashkenas/coffeescript/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-11T18:35:35Z","updated_at":"2015-09-13T05:22:09Z","closed_at":null,"body":"I really want an existential splat operator:\r\n\r\n```coffee\r\na(b, c...)\r\n```\r\n\r\ncompiles to\r\n\r\n```javascript\r\na.apply(null, [b].concat(slice.call(c)));\r\n```\r\n\r\nwhich fails when `c` is `null` or `undefined`\r\n\r\nIt would be nice to have a syntax like:\r\n\r\n```coffee\r\na(b, c?...)\r\n```\r\n\r\ncompiles to\r\n\r\n```javascript\r\na.apply(null, typeof c !== \"undefined\" && c !== null ? [b].concat(slice.call(c)) : [b]);\r\n```\r\n\r\nIs there any reason not to do this?"},"comment":{"url":"https://api.github.com/repos/jashkenas/coffeescript/issues/comments/139845167","html_url":"https://github.com/jashkenas/coffeescript/issues/4091#issuecomment-139845167","issue_url":"https://api.github.com/repos/jashkenas/coffeescript/issues/4091","id":139845167,"user":{"login":"olleicua","id":1270102,"avatar_url":"https://avatars.githubusercontent.com/u/1270102?v=3","gravatar_id":"","url":"https://api.github.com/users/olleicua","html_url":"https://github.com/olleicua","followers_url":"https://api.github.com/users/olleicua/followers","following_url":"https://api.github.com/users/olleicua/following{/other_user}","gists_url":"https://api.github.com/users/olleicua/gists{/gist_id}","starred_url":"https://api.github.com/users/olleicua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olleicua/subscriptions","organizations_url":"https://api.github.com/users/olleicua/orgs","repos_url":"https://api.github.com/users/olleicua/repos","events_url":"https://api.github.com/users/olleicua/events{/privacy}","received_events_url":"https://api.github.com/users/olleicua/received_events","type":"User","site_admin":false},"created_at":"2015-09-13T05:22:09Z","updated_at":"2015-09-13T05:22:09Z","body":"I'm looking into implementing this.  It's tricky for a couple of reasons:\r\n\r\nWhen I tried the naive solution:\r\n\r\n```coffee\r\n  # A splat that occurs outside of a parameter list.\r\n  Splat: [\r\n    o 'Expression ? ...',                       -> new Splat new Existence $1\r\n    o 'Expression ...',                         -> new Splat $1\r\n  ]\r\n```\r\n\r\nJison gives me a grammar conflict:\r\n\r\n```\r\nConflict in grammar: multiple actions possible when lookahead token is ... in state 243\r\n- reduce by rule: Operation -> Expression ?\r\n- shift token (then go to state 293)\r\n\r\nStates with conflicts:\r\nState 243\r\n  Operation -> Expression ? . #lookaheads= ... .. , ] FOR UNTIL WHILE POST_IF RELATION LOGIC COMPARE SHIFT ** MATH - + ? INDENT TERMINATOR CALL_END OUTDENT\r\n  Splat -> Expression ? .... #lookaheads= ] , TERMINATOR INDENT CALL_END OUTDENT\r\n```\r\n\r\nThe best solution I can think of is to modify the lexer to pick out `?...` as a separate token.  I'm currently pouring over the lexer to see if I can figure out how best to do that.\r\n\r\nAlso, I'm realizing that the existing `Existence` node isn't quite what I want because I want `null` and `undefined` to be replace with `[]`.  In light of this I'm guessing I will either need to modify the `Splat` node or make a new `ExistentialSplat` node.  The latter seems less likely to interfere with existing code.\r\n\r\nAny advice or direction on this would be greatly appreciated."}}