{"action":"created","issue":{"url":"https://api.github.com/repos/ocaml/ocaml/issues/780","repository_url":"https://api.github.com/repos/ocaml/ocaml","labels_url":"https://api.github.com/repos/ocaml/ocaml/issues/780/labels{/name}","comments_url":"https://api.github.com/repos/ocaml/ocaml/issues/780/comments","events_url":"https://api.github.com/repos/ocaml/ocaml/issues/780/events","html_url":"https://github.com/ocaml/ocaml/pull/780","id":173211323,"number":780,"title":"Handle specialisation of recursive function that does not always preserve the arguments (MPR#7291)","user":{"login":"chambart","id":2196625,"avatar_url":"https://avatars.githubusercontent.com/u/2196625?v=3","gravatar_id":"","url":"https://api.github.com/users/chambart","html_url":"https://github.com/chambart","followers_url":"https://api.github.com/users/chambart/followers","following_url":"https://api.github.com/users/chambart/following{/other_user}","gists_url":"https://api.github.com/users/chambart/gists{/gist_id}","starred_url":"https://api.github.com/users/chambart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chambart/subscriptions","organizations_url":"https://api.github.com/users/chambart/orgs","repos_url":"https://api.github.com/users/chambart/repos","events_url":"https://api.github.com/users/chambart/events{/privacy}","received_events_url":"https://api.github.com/users/chambart/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ocaml/ocaml/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/ocaml/ocaml/milestones/2","html_url":"https://github.com/ocaml/ocaml/milestones/4.04","labels_url":"https://api.github.com/repos/ocaml/ocaml/milestones/2/labels","id":1464889,"number":2,"title":"4.04","description":"","creator":{"login":"damiendoligez","id":19104,"avatar_url":"https://avatars.githubusercontent.com/u/19104?v=3","gravatar_id":"","url":"https://api.github.com/users/damiendoligez","html_url":"https://github.com/damiendoligez","followers_url":"https://api.github.com/users/damiendoligez/followers","following_url":"https://api.github.com/users/damiendoligez/following{/other_user}","gists_url":"https://api.github.com/users/damiendoligez/gists{/gist_id}","starred_url":"https://api.github.com/users/damiendoligez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/damiendoligez/subscriptions","organizations_url":"https://api.github.com/users/damiendoligez/orgs","repos_url":"https://api.github.com/users/damiendoligez/repos","events_url":"https://api.github.com/users/damiendoligez/events{/privacy}","received_events_url":"https://api.github.com/users/damiendoligez/received_events","type":"User","site_admin":false},"open_issues":8,"closed_issues":95,"state":"open","created_at":"2015-12-17T12:44:22Z","updated_at":"2016-10-05T15:38:39Z","due_on":"2016-07-17T22:00:00Z","closed_at":null},"comments":12,"created_at":"2016-08-25T14:02:01Z","updated_at":"2016-10-05T15:41:46Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ocaml/ocaml/pulls/780","html_url":"https://github.com/ocaml/ocaml/pull/780","diff_url":"https://github.com/ocaml/ocaml/pull/780.diff","patch_url":"https://github.com/ocaml/ocaml/pull/780.patch"},"body":"This is a followup to https://github.com/ocaml/ocaml/pull/731\r\n\r\nThe other solution to fixing [MPR#7291](http://caml.inria.fr/mantis/view.php?id=7291) is to drop the requirement from the parameter invariance analysis from being an over-approximation.\r\n\r\nThis is done by some rewriting of specialised functions before freshening. Every recursive calls that are not obviously preserving the arguments that will be specialised call the original function instead of a recursive call to the specialised version.\r\n\r\nThis is a bit more complex than originally expected to be able to multiply recursive functions like:\r\n```OCaml\r\ntype a =\r\n  | A of b\r\n  | End\r\n\r\nand b =\r\n  | B of a\r\n\r\nlet rec iter_a f a =\r\n  match a with\r\n  | A b ->\r\n    f ();\r\n    iter_b f b\r\n  | End ->\r\n    ()\r\n\r\nand iter_b f b =\r\n  match b with\r\n  | B a ->\r\n    f ();\r\n    iter_a f a\r\n\r\n\r\nlet count a =\r\n  let r = ref 0 in\r\n  let increm () = incr r in\r\n  (iter_a [@specialised]) increm a;\r\n  !r\r\n```\r\n\r\nThis change is not the most efficient possible: There are 3 added rewritings of the functions.\r\nSome could be eliminated. This is only a first proposal."},"comment":{"url":"https://api.github.com/repos/ocaml/ocaml/issues/comments/251712994","html_url":"https://github.com/ocaml/ocaml/pull/780#issuecomment-251712994","issue_url":"https://api.github.com/repos/ocaml/ocaml/issues/780","id":251712994,"user":{"login":"lpw25","id":2631210,"avatar_url":"https://avatars.githubusercontent.com/u/2631210?v=3","gravatar_id":"","url":"https://api.github.com/users/lpw25","html_url":"https://github.com/lpw25","followers_url":"https://api.github.com/users/lpw25/followers","following_url":"https://api.github.com/users/lpw25/following{/other_user}","gists_url":"https://api.github.com/users/lpw25/gists{/gist_id}","starred_url":"https://api.github.com/users/lpw25/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lpw25/subscriptions","organizations_url":"https://api.github.com/users/lpw25/orgs","repos_url":"https://api.github.com/users/lpw25/repos","events_url":"https://api.github.com/users/lpw25/events{/privacy}","received_events_url":"https://api.github.com/users/lpw25/received_events","type":"User","site_admin":false},"created_at":"2016-10-05T15:41:46Z","updated_at":"2016-10-05T15:41:46Z","body":"I think we are waiting for @chambart to return from vacation before making a decision"}}
{"actor":{"display_login":"lpw25"}}