{"action":"created","issue":{"url":"https://api.github.com/repos/WebAssembly/design/issues/295","labels_url":"https://api.github.com/repos/WebAssembly/design/issues/295/labels{/name}","comments_url":"https://api.github.com/repos/WebAssembly/design/issues/295/comments","events_url":"https://api.github.com/repos/WebAssembly/design/issues/295/events","html_url":"https://github.com/WebAssembly/design/issues/295","id":100668646,"number":295,"title":"More rationale on the choice of pre-order and control structures in the binary format","user":{"login":"gwvo","id":6145400,"avatar_url":"https://avatars.githubusercontent.com/u/6145400?v=3","gravatar_id":"","url":"https://api.github.com/users/gwvo","html_url":"https://github.com/gwvo","followers_url":"https://api.github.com/users/gwvo/followers","following_url":"https://api.github.com/users/gwvo/following{/other_user}","gists_url":"https://api.github.com/users/gwvo/gists{/gist_id}","starred_url":"https://api.github.com/users/gwvo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gwvo/subscriptions","organizations_url":"https://api.github.com/users/gwvo/orgs","repos_url":"https://api.github.com/users/gwvo/repos","events_url":"https://api.github.com/users/gwvo/events{/privacy}","received_events_url":"https://api.github.com/users/gwvo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-13T01:09:44Z","updated_at":"2015-08-13T01:25:57Z","closed_at":null,"body":"This section:\r\nhttps://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#serialized-ast\r\ncould use some more rationale as to why a pre-order encoding is being used.\r\nIt also says \"Allows context-dependent index spaces (described above)\", which is not obvious what that refers to, nor do I see how that would depend on it being pre-order.\r\n\r\nIn fact, I can see advantages to post-order representation:\r\n  * Allows things like validation or building up a tree by using nothing but a temporary node stack, and\r\n    an otherwise very linear parser. Pre-order can be equally efficient if you want, but it fits recursive\r\n    parsing more naturally.\r\n  * Closer fit to backends that use stack-machines in some way.\r\n\r\nRelated to that, some more rationale on requiring backends to use a relooper-like algorithm to produce a limited set of control structures. I understand it results in the absolutely smallest binary, but the algorithm is not entirely non-trivial, and it feels.. less elegant to require this when most backends will have a branch/graph based representation they're working from, and V8 etc presumably also needing to convert this back to a more general representation.\r\n\r\nWhat alternatives have been considered? If the top level of a block is a list of \"statements\", could a (conditional) branch node that refers to a statement index work also, at a small cost in binary size, but be more generic in what kind of structures it represents, being easier to generate and decode etc.?"},"comment":{"url":"https://api.github.com/repos/WebAssembly/design/issues/comments/130498355","html_url":"https://github.com/WebAssembly/design/issues/295#issuecomment-130498355","issue_url":"https://api.github.com/repos/WebAssembly/design/issues/295","id":130498355,"user":{"login":"jfbastien","id":298127,"avatar_url":"https://avatars.githubusercontent.com/u/298127?v=3","gravatar_id":"","url":"https://api.github.com/users/jfbastien","html_url":"https://github.com/jfbastien","followers_url":"https://api.github.com/users/jfbastien/followers","following_url":"https://api.github.com/users/jfbastien/following{/other_user}","gists_url":"https://api.github.com/users/jfbastien/gists{/gist_id}","starred_url":"https://api.github.com/users/jfbastien/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfbastien/subscriptions","organizations_url":"https://api.github.com/users/jfbastien/orgs","repos_url":"https://api.github.com/users/jfbastien/repos","events_url":"https://api.github.com/users/jfbastien/events{/privacy}","received_events_url":"https://api.github.com/users/jfbastien/received_events","type":"User","site_admin":false},"created_at":"2015-08-13T01:25:57Z","updated_at":"2015-08-13T01:25:57Z","body":"Side note: I believe @LouisLaf had concerns in https://github.com/WebAssembly/design/issues/239#issuecomment-118993642, the surrounding discussion provides good context.\r\n\r\nAgreed that we should clarify."}}