{"action":"created","issue":{"url":"https://api.github.com/repos/WebAssembly/design/issues/310","labels_url":"https://api.github.com/repos/WebAssembly/design/issues/310/labels{/name}","comments_url":"https://api.github.com/repos/WebAssembly/design/issues/310/comments","events_url":"https://api.github.com/repos/WebAssembly/design/issues/310/events","html_url":"https://github.com/WebAssembly/design/issues/310","id":102855608,"number":310,"title":"Eliminate `continue` statement","user":{"login":"rossberg-chromium","id":4247099,"avatar_url":"https://avatars.githubusercontent.com/u/4247099?v=3","gravatar_id":"","url":"https://api.github.com/users/rossberg-chromium","html_url":"https://github.com/rossberg-chromium","followers_url":"https://api.github.com/users/rossberg-chromium/followers","following_url":"https://api.github.com/users/rossberg-chromium/following{/other_user}","gists_url":"https://api.github.com/users/rossberg-chromium/gists{/gist_id}","starred_url":"https://api.github.com/users/rossberg-chromium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rossberg-chromium/subscriptions","organizations_url":"https://api.github.com/users/rossberg-chromium/orgs","repos_url":"https://api.github.com/users/rossberg-chromium/repos","events_url":"https://api.github.com/users/rossberg-chromium/events{/privacy}","received_events_url":"https://api.github.com/users/rossberg-chromium/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/WebAssembly/design/labels/control%20flow","name":"control flow","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/WebAssembly/design/milestones/2","html_url":"https://github.com/WebAssembly/design/milestones/MVP","labels_url":"https://api.github.com/repos/WebAssembly/design/milestones/2/labels","id":1138963,"number":2,"title":"MVP","description":"","creator":{"login":"sunfishcode","id":4503403,"avatar_url":"https://avatars.githubusercontent.com/u/4503403?v=3","gravatar_id":"","url":"https://api.github.com/users/sunfishcode","html_url":"https://github.com/sunfishcode","followers_url":"https://api.github.com/users/sunfishcode/followers","following_url":"https://api.github.com/users/sunfishcode/following{/other_user}","gists_url":"https://api.github.com/users/sunfishcode/gists{/gist_id}","starred_url":"https://api.github.com/users/sunfishcode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sunfishcode/subscriptions","organizations_url":"https://api.github.com/users/sunfishcode/orgs","repos_url":"https://api.github.com/users/sunfishcode/repos","events_url":"https://api.github.com/users/sunfishcode/events{/privacy}","received_events_url":"https://api.github.com/users/sunfishcode/received_events","type":"User","site_admin":false},"open_issues":28,"closed_issues":9,"state":"open","created_at":"2015-05-29T00:13:49Z","updated_at":"2015-08-30T01:48:57Z","due_on":null,"closed_at":null},"comments":12,"created_at":"2015-08-24T18:04:32Z","updated_at":"2015-08-31T16:11:26Z","closed_at":null,"body":"In a language with break-from-block, the `continue` statement is redundant. Any loop of the form\r\n```\r\nl: while (C) { ... continue l; ... }\r\n```\r\ncan equivalently be rewritten to\r\n```\r\nl: while (C) l2: { ... break l2; ... }\r\n```\r\nWhile a separate `continue` statement is useful in user-facing syntax, I see no benefit in having it in Wasm. In particular, since labels are implicit, so there isn't even any encoding overhead in the second form.\r\n\r\nI propose removing `continue`."},"comment":{"url":"https://api.github.com/repos/WebAssembly/design/issues/comments/136417393","html_url":"https://github.com/WebAssembly/design/issues/310#issuecomment-136417393","issue_url":"https://api.github.com/repos/WebAssembly/design/issues/310","id":136417393,"user":{"login":"AndrewScheidecker","id":2691804,"avatar_url":"https://avatars.githubusercontent.com/u/2691804?v=3","gravatar_id":"","url":"https://api.github.com/users/AndrewScheidecker","html_url":"https://github.com/AndrewScheidecker","followers_url":"https://api.github.com/users/AndrewScheidecker/followers","following_url":"https://api.github.com/users/AndrewScheidecker/following{/other_user}","gists_url":"https://api.github.com/users/AndrewScheidecker/gists{/gist_id}","starred_url":"https://api.github.com/users/AndrewScheidecker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndrewScheidecker/subscriptions","organizations_url":"https://api.github.com/users/AndrewScheidecker/orgs","repos_url":"https://api.github.com/users/AndrewScheidecker/repos","events_url":"https://api.github.com/users/AndrewScheidecker/events{/privacy}","received_events_url":"https://api.github.com/users/AndrewScheidecker/received_events","type":"User","site_admin":false},"created_at":"2015-08-31T16:11:26Z","updated_at":"2015-08-31T16:11:26Z","body":"I think the primary benefit to eliminating the continue operation is that it simplifies the AST context; e.g. the context to mimic the JavaScript break and continue semantics as the binary encoding from the polyfill prototype requires is annoying. Another way to simplify the context (and eliminate continue) without requiring extra label nodes is to give loop nodes two branch targets: one for break, and one for continue.\r\n\r\ne.g. this WebAssembly: ```(loop $break $continue ... (branch $continue) ... (branch $break) ...)```\r\ncould translate to this JavaScript: ```a: while(true) { ... continue a; ... break a; ... }```\r\nand can also be easily translated to lower level branching operations.\r\n\r\nIncidentally, I also think the text format should eventually require referencing labels, locals, and globals by name; that would mean only consumers of the binary format need to understand indexing. With rules like loops introducing two labels, or separate index spaces for locals by type, that's potentially a lot of complexity that could be isolated to the binary format. It makes sense to keep the indexing in the text format for prototyping, but once the reference interpreter also implements a binary format, it would be nice to get rid of it."}}