{"action":"created","issue":{"url":"https://api.github.com/repos/WebAssembly/spec/issues/258","repository_url":"https://api.github.com/repos/WebAssembly/spec","labels_url":"https://api.github.com/repos/WebAssembly/spec/issues/258/labels{/name}","comments_url":"https://api.github.com/repos/WebAssembly/spec/issues/258/comments","events_url":"https://api.github.com/repos/WebAssembly/spec/issues/258/events","html_url":"https://github.com/WebAssembly/spec/issues/258","id":136743374,"number":258,"title":"Metadata in s-expression? atoms","user":{"login":"yurydelendik","id":1523410,"avatar_url":"https://avatars.githubusercontent.com/u/1523410?v=3","gravatar_id":"","url":"https://api.github.com/users/yurydelendik","html_url":"https://github.com/yurydelendik","followers_url":"https://api.github.com/users/yurydelendik/followers","following_url":"https://api.github.com/users/yurydelendik/following{/other_user}","gists_url":"https://api.github.com/users/yurydelendik/gists{/gist_id}","starred_url":"https://api.github.com/users/yurydelendik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yurydelendik/subscriptions","organizations_url":"https://api.github.com/users/yurydelendik/orgs","repos_url":"https://api.github.com/users/yurydelendik/repos","events_url":"https://api.github.com/users/yurydelendik/events{/privacy}","received_events_url":"https://api.github.com/users/yurydelendik/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-26T16:23:22Z","updated_at":"2016-02-26T22:51:06Z","closed_at":null,"body":"Most of the languages have some way of expressing code metadata on the source level. It's probably not an issue for binary format since it's easy to add unknown sections [1] that will refer encoded op-codes/data by offsets in the e.g. function sections. However the wast/s-expression is missing this capability, and currently this format is heavily used for prototyping. While it's possible to provide this information as comment e.g. with '!' added `(;!DILocation (line 2) (column 9) (scope (!4)));)`, it will be nice to define it as a syntax and probably skip/ignore that for MVP (as we do it for the comments). What we are trying to reach here is some verifiable structure for the nested metadata tags.\r\n\r\nThe main use case is to include source-level debug information into intermediate WebAssembly language. At the end we would like to see something like LLVM has (see [2] and [3]). Perhaps something like:\r\n\r\n```\r\n  ...\r\n  (!dgb $1)\r\n  (func (!dbg $2) (param i64) (result i64)\r\n    (!dbg $3) (if_else (i64.eq (get_local 0) (i64.const 0))\r\n      (!dbg $4) (i64.const 1)\r\n      (!dbg $5) (i64.mul (get_local 0) (call 0 (i64.sub (get_local 0) (i64.const 1))))\r\n    )\r\n  )\r\n  (!set $0 (!DIFile (filename \"src/factorial.cpp\")))\r\n  (!set $1 (!DISubprogram (name \"fac_rec\") (file $0)))\r\n  (!set $2 (!DILocalVariable (name \"n\") (scope $1)))\r\n  (!set $3 (!DILocation (line 2) (column 9) (scope $1)))\r\n  ...\r\n```\r\n\r\nThe main idea will be to associate some metadata with s-expression list nodes, but still be something we can validate and serialize to/deserialize from binary format. \r\n\r\n(Related issues found [4]) \r\n\r\n  [1] https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#unknown-sections\r\n  [2] http://llvm.org/docs/LangRef.html#metadata\r\n  [3] http://llvm.org/docs/SourceLevelDebugging.html#object-lifetimes-and-scoping\r\n  [4] https://github.com/WebAssembly/design/issues/208"},"comment":{"url":"https://api.github.com/repos/WebAssembly/spec/issues/comments/189515573","html_url":"https://github.com/WebAssembly/spec/issues/258#issuecomment-189515573","issue_url":"https://api.github.com/repos/WebAssembly/spec/issues/258","id":189515573,"user":{"login":"mbebenita","id":311082,"avatar_url":"https://avatars.githubusercontent.com/u/311082?v=3","gravatar_id":"","url":"https://api.github.com/users/mbebenita","html_url":"https://github.com/mbebenita","followers_url":"https://api.github.com/users/mbebenita/followers","following_url":"https://api.github.com/users/mbebenita/following{/other_user}","gists_url":"https://api.github.com/users/mbebenita/gists{/gist_id}","starred_url":"https://api.github.com/users/mbebenita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbebenita/subscriptions","organizations_url":"https://api.github.com/users/mbebenita/orgs","repos_url":"https://api.github.com/users/mbebenita/repos","events_url":"https://api.github.com/users/mbebenita/events{/privacy}","received_events_url":"https://api.github.com/users/mbebenita/received_events","type":"User","site_admin":false},"created_at":"2016-02-26T22:51:06Z","updated_at":"2016-02-26T22:51:06Z","body":"These mark nodes should probably behave kind of like blocks that yield the last value, something like:\r\n\r\n```\r\n(mark $1\r\n  (func (mark $2 (param i64)) (result i64)\r\n    (mark $3 \r\n      (if_else (i64.eq (get_local 0) (i64.const 0))\r\n        (mark $4 (i64.const 1))\r\n        (mark $5 (i64.mul (get_local 0) (call 0 (i64.sub (get_local 0) (i64.const 1)))))\r\n      )\r\n    )\r\n  )\r\n)\r\n```\r\n\r\nThis way you could also refer to a region of the AST, the exact meaning of what you're referring to depends on the use."}}