{"action":"created","issue":{"url":"https://api.github.com/repos/ocaml/ocaml/issues/240","labels_url":"https://api.github.com/repos/ocaml/ocaml/issues/240/labels{/name}","comments_url":"https://api.github.com/repos/ocaml/ocaml/issues/240/comments","events_url":"https://api.github.com/repos/ocaml/ocaml/issues/240/events","html_url":"https://github.com/ocaml/ocaml/pull/240","id":107192688,"number":240,"title":"Replace \"noalloc\" and \"float\" by attributes","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":4,"created_at":"2015-09-18T12:24:28Z","updated_at":"2015-09-18T14:57:54Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ocaml/ocaml/pulls/240","html_url":"https://github.com/ocaml/ocaml/pull/240","diff_url":"https://github.com/ocaml/ocaml/pull/240.diff","patch_url":"https://github.com/ocaml/ocaml/pull/240.patch"},"body":"OCaml allows to annotate externals with `\"noalloc\"` and `\"float\"`, as follow:\r\n\r\n```ocaml\r\nexternal f : float -> float = \"byte-code-func\" \"noalloc\" \"native-code-func\" \"float\"\r\n```\r\n\r\nBut this is a bit tedious as `\"noalloc\"` and `\"float\"` are only recognized if they are at the right place in the list of strings. Moreover the manual just says that the strings after the `=` are supposed to be either:\r\n\r\n- `\"stub\"`\r\n- `\"byte-code stub\" \"native-code stub\"`\r\n\r\nNow that we have attributes, it seems natural to use attributes for these annotations. This patch introduces the following attributes on external declarations:\r\n\r\n- `[@@noalloc]` to replace `\"noalloc\"`\r\n- `[@@unboxed]` to generalize `\"float\"`. It has the same effect as adding `[@unboxed]` to all arguments and the result but is syntactically lighter\r\n- `[@@untagged]` for consistency with `[@@unboxed]`\r\n\r\nThe above declaration can be rewritten:\r\n\r\n```ocaml\r\nexternal f : float -> float = \"byte-code-func\" \"native-code-func\" [@@noalloc] [@@unboxed]\r\n```\r\n\r\nThe patch also updates external declarations in the stdlib and otherlibs. Declaration that were marked with only `\"float\"` are now marked with both `[@@noalloc]` and `[@@unboxed]`. This is because  `\"noalloc\"` is assumed when `\"float\"` is present.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ocaml/ocaml/issues/comments/141475866","html_url":"https://github.com/ocaml/ocaml/pull/240#issuecomment-141475866","issue_url":"https://api.github.com/repos/ocaml/ocaml/issues/240","id":141475866,"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-09-18T14:57:54Z","updated_at":"2015-09-18T14:57:54Z","body":"I do think the code is mergeable in its current state."}}