{"action":"created","issue":{"url":"https://api.github.com/repos/ocaml/ocaml/issues/273","labels_url":"https://api.github.com/repos/ocaml/ocaml/issues/273/labels{/name}","comments_url":"https://api.github.com/repos/ocaml/ocaml/issues/273/comments","events_url":"https://api.github.com/repos/ocaml/ocaml/issues/273/events","html_url":"https://github.com/ocaml/ocaml/pull/273","id":114256969,"number":273,"title":"Get extension slot","user":{"login":"diml","id":1251584,"avatar_url":"https://avatars.githubusercontent.com/u/1251584?v=3","gravatar_id":"","url":"https://api.github.com/users/diml","html_url":"https://github.com/diml","followers_url":"https://api.github.com/users/diml/followers","following_url":"https://api.github.com/users/diml/following{/other_user}","gists_url":"https://api.github.com/users/diml/gists{/gist_id}","starred_url":"https://api.github.com/users/diml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/diml/subscriptions","organizations_url":"https://api.github.com/users/diml/orgs","repos_url":"https://api.github.com/users/diml/repos","events_url":"https://api.github.com/users/diml/events{/privacy}","received_events_url":"https://api.github.com/users/diml/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-10-30T12:02:46Z","updated_at":"2015-11-18T14:22:30Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ocaml/ocaml/pulls/273","html_url":"https://github.com/ocaml/ocaml/pull/273","diff_url":"https://github.com/ocaml/ocaml/pull/273.diff","patch_url":"https://github.com/ocaml/ocaml/pull/273.patch"},"body":"This patch adds support for `[%extension_slot <path>]`. The compiler expands it to the slot of the extension constructor denoted by `<path>`. For instance:\r\n\r\n```ocaml\r\ntype t = ..\r\ntype t += A of int\r\n\r\nlet () = assert (Obj.extension_slot (A 42) == [%extension_slot A])\r\n```\r\n\r\nThe motivation for this request is ppx rewriters that needs to register a value associated to and extension constructor, such as what sexplib does for exceptions, and should do soon for all open types.\r\n\r\nCurrently the only way to get the extension slot is to build a dummy value, which is difficult to do in a ppx rewriter. In sexplib for instance we have a module [Exn_magic](https://github.com/janestreet/sexplib/blob/master/lib/exn_magic.mli) that is full of `Obj.magic` to deal with that."},"comment":{"url":"https://api.github.com/repos/ocaml/ocaml/issues/comments/157726991","html_url":"https://github.com/ocaml/ocaml/pull/273#issuecomment-157726991","issue_url":"https://api.github.com/repos/ocaml/ocaml/issues/273","id":157726991,"user":{"login":"gasche","id":426238,"avatar_url":"https://avatars.githubusercontent.com/u/426238?v=3","gravatar_id":"","url":"https://api.github.com/users/gasche","html_url":"https://github.com/gasche","followers_url":"https://api.github.com/users/gasche/followers","following_url":"https://api.github.com/users/gasche/following{/other_user}","gists_url":"https://api.github.com/users/gasche/gists{/gist_id}","starred_url":"https://api.github.com/users/gasche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gasche/subscriptions","organizations_url":"https://api.github.com/users/gasche/orgs","repos_url":"https://api.github.com/users/gasche/repos","events_url":"https://api.github.com/users/gasche/events{/privacy}","received_events_url":"https://api.github.com/users/gasche/received_events","type":"User","site_admin":false},"created_at":"2015-11-18T14:22:30Z","updated_at":"2015-11-18T14:22:30Z","body":"Xavier would like us to find a better name than \"extension slot\" for this concept, described by Leo and Mark in stereo as \"the thing that gets allocated when we declare a new extension constructor\"."}}