{"action":"created","issue":{"url":"https://api.github.com/repos/WebAssembly/design/issues/650","repository_url":"https://api.github.com/repos/WebAssembly/design","labels_url":"https://api.github.com/repos/WebAssembly/design/issues/650/labels{/name}","comments_url":"https://api.github.com/repos/WebAssembly/design/issues/650/comments","events_url":"https://api.github.com/repos/WebAssembly/design/issues/650/events","html_url":"https://github.com/WebAssembly/design/issues/650","id":147073464,"number":650,"title":"Add a block1 operator that returns the values of the first expression and discards the rest.","user":{"login":"JSStats","id":11826073,"avatar_url":"https://avatars.githubusercontent.com/u/11826073?v=3","gravatar_id":"","url":"https://api.github.com/users/JSStats","html_url":"https://github.com/JSStats","followers_url":"https://api.github.com/users/JSStats/followers","following_url":"https://api.github.com/users/JSStats/following{/other_user}","gists_url":"https://api.github.com/users/JSStats/gists{/gist_id}","starred_url":"https://api.github.com/users/JSStats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JSStats/subscriptions","organizations_url":"https://api.github.com/users/JSStats/orgs","repos_url":"https://api.github.com/users/JSStats/repos","events_url":"https://api.github.com/users/JSStats/events{/privacy}","received_events_url":"https://api.github.com/users/JSStats/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2016-04-09T00:53:04Z","updated_at":"2016-04-17T04:03:18Z","closed_at":"2016-04-16T08:18:17Z","body":"The `block` operator returns the values of the last expression but it is a common pattern to need to return values from other expressions in a block and this current requires the use of local variables. Adding a `block1` operator that returns the values of the first expression would allow these pattern to be expressed as expressions without using local variables. The combination of `block` and `block1` allows the results of an arbitrary expression to be returned.\r\n\r\nFor example to return the values of the second expression in an effective block of expressions the following is currently required:\r\n\r\n```\r\n(block\r\n  (expression1)\r\n  (set_local $v1 (expression2))\r\n  (expression3)\r\n  (get_local $v1))\r\n```\r\n\r\nWith a `block1` operator this could be:\r\n```\r\n(block\r\n  (expression1)\r\n  (block1\r\n     (expression2)\r\n     (expression 3)))\r\n```\r\n\r\nWhen the result expression has multiple values, using local variables in this pattern becomes even more verbose making `block1` more compelling.\r\n\r\n@sunfishcode Can you see an obvious way for the llvm backend to exploit this?\r\n"},"comment":{"url":"https://api.github.com/repos/WebAssembly/design/issues/comments/210949524","html_url":"https://github.com/WebAssembly/design/issues/650#issuecomment-210949524","issue_url":"https://api.github.com/repos/WebAssembly/design/issues/650","id":210949524,"user":{"login":"qwertie","id":720717,"avatar_url":"https://avatars.githubusercontent.com/u/720717?v=3","gravatar_id":"","url":"https://api.github.com/users/qwertie","html_url":"https://github.com/qwertie","followers_url":"https://api.github.com/users/qwertie/followers","following_url":"https://api.github.com/users/qwertie/following{/other_user}","gists_url":"https://api.github.com/users/qwertie/gists{/gist_id}","starred_url":"https://api.github.com/users/qwertie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qwertie/subscriptions","organizations_url":"https://api.github.com/users/qwertie/orgs","repos_url":"https://api.github.com/users/qwertie/repos","events_url":"https://api.github.com/users/qwertie/events{/privacy}","received_events_url":"https://api.github.com/users/qwertie/received_events","type":"User","site_admin":false},"created_at":"2016-04-17T04:03:18Z","updated_at":"2016-04-17T04:03:18Z","body":"I've been meaning to say, this feature strikes me as useful in any situation where \"destructor\" or \"finally\" logic has to run:\r\n\r\n    int Foo()\r\n    {\r\n       HasDestructor thing();\r\n       return thing.Computation1() + thing.Computation2();\r\n    }\r\n\r\nOnce inlining is done, this will often happen inside functions, not just at the edges. Plus, a compiler that optimizes for size it might find more ways to use `block1`.\r\n\r\nWhere did the discussion of `let` take place?"}}