{"action":"created","comment":{"url":"https://api.github.com/repos/ocaml/ocaml/pulls/comments/235291041","pull_request_review_id":177119850,"id":235291041,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNTI5MTA0MQ==","diff_hunk":"@@ -138,10 +138,25 @@ val print_out_phrase :\n \n val read_interactive_input : (string -> bytes -> int -> int * bool) ref\n \n-(* Hooks for initialization *)\n+(* Hooks *)\n \n val toplevel_startup_hook : (unit -> unit) ref\n \n+type event =\n+  | Startup\n+  | After_setup","path":"toplevel/toploop.mli","position":11,"original_position":11,"commit_id":"25353267f098157cab6621081ff5b5898dec11f0","original_commit_id":"25353267f098157cab6621081ff5b5898dec11f0","user":{"login":"dra27","id":5250680,"node_id":"MDQ6VXNlcjUyNTA2ODA=","avatar_url":"https://avatars0.githubusercontent.com/u/5250680?v=4","gravatar_id":"","url":"https://api.github.com/users/dra27","html_url":"https://github.com/dra27","followers_url":"https://api.github.com/users/dra27/followers","following_url":"https://api.github.com/users/dra27/following{/other_user}","gists_url":"https://api.github.com/users/dra27/gists{/gist_id}","starred_url":"https://api.github.com/users/dra27/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dra27/subscriptions","organizations_url":"https://api.github.com/users/dra27/orgs","repos_url":"https://api.github.com/users/dra27/repos","events_url":"https://api.github.com/users/dra27/events{/privacy}","received_events_url":"https://api.github.com/users/dra27/received_events","type":"User","site_admin":false},"body":"It looks like it becomes necessary for self-contained toplevels?","created_at":"2018-11-21T08:31:56Z","updated_at":"2018-11-21T08:37:38Z","html_url":"https://github.com/ocaml/ocaml/pull/2041#discussion_r235291041","pull_request_url":"https://api.github.com/repos/ocaml/ocaml/pulls/2041","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/ocaml/ocaml/pulls/comments/235291041"},"html":{"href":"https://github.com/ocaml/ocaml/pull/2041#discussion_r235291041"},"pull_request":{"href":"https://api.github.com/repos/ocaml/ocaml/pulls/2041"}},"in_reply_to_id":219274898},"pull_request":{"url":"https://api.github.com/repos/ocaml/ocaml/pulls/2041","id":214718718,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE0NzE4NzE4","html_url":"https://github.com/ocaml/ocaml/pull/2041","diff_url":"https://github.com/ocaml/ocaml/pull/2041.diff","patch_url":"https://github.com/ocaml/ocaml/pull/2041.patch","issue_url":"https://api.github.com/repos/ocaml/ocaml/issues/2041","number":2041,"state":"open","locked":false,"title":"Refactor the construction of the initial environment (fixes #7841)","user":{"login":"diml","id":1251584,"node_id":"MDQ6VXNlcjEyNTE1ODQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1251584?v=4","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},"body":"This PR is a work in progress, I'm opening it for early feedback and to make sure I'm approaching the problem the right way, as it is taking longer than I expected.\r\n\r\n## Overview\r\n\r\nThis PR refactors the way include directories and handled. In particular, it allows modules implemented by external cmi files to shadow modules in the current environment. The main motivation is so that modules coming from include directories specified by the user have precedence over the implicit `open Stdlib`  performed by the compiler.\r\n\r\nThis is already the case, however the way it is implemented is not very elegant and doesn't work when incrementally adding include directories, such as in the toplevel.\r\n\r\n## More details\r\n\r\nIn the current world, the environment is split in two:\r\n\r\n1. a local in-memory environment\r\n2. a mapping from module names to external cmi files, specified via a list of include directories\r\n\r\n1 always have precedence over 2 which is only used as a fallback for modules that are not found in 1. In particular if we consider the following toplevel session:\r\n\r\n```\r\n# module X = struct end;;\r\n# #directory \"foo\";;\r\n```\r\n\r\nIt is impossible to refer to the compilation unit `X` stored in `foo/x.cmi` because the local `X` has precedence over external modules.\r\n\r\nThis PRs removes the fallback  to 2 and replaces it by a new primitive that allows to add a persistent module to the environment. This means that adding an include directory becomes an operation that eagerly add names to the environment, shadowing existing ones. However, the cmi files are still loaded lazily.\r\n\r\nIf we reuse the DSL from #1513, this means the initial environment is now effectively constructed as follow:\r\n\r\n```\r\nenv <- empty\r\n\r\nenv <- add_dir(env, stdlib_dir)\r\nenv <- open(env, Stdlib)\r\n\r\nenv <- add_dir(env, d1)\r\n...\r\nenv <- add_dir(env, dn)\r\n\r\nenv <- open(env, M1)\r\n...\r\nenv <- open(env, Mm)\r\n```\r\n\r\nWhere `dX` are the include directories specified by the user via the `-I` option and `MX` are the implicitly opened modules specified via `-open`. In the toplevel, the `#directory <dir>` directive is immediate interpreted as: `env <- add_dir(env, dir)`. So if we consider the toplevel session above, after `#directory \"foo\"`, `X`  refers to `foo/x.cmi` rather than the local module `X`. This seems like a better behavior to me.\r\n","created_at":"2018-09-11T18:08:09Z","updated_at":"2018-11-21T08:37:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"10e8166d77ce235ae90b8072e7186225bbb9afb1","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":{"url":"https://api.github.com/repos/ocaml/ocaml/milestones/15","html_url":"https://github.com/ocaml/ocaml/milestone/15","labels_url":"https://api.github.com/repos/ocaml/ocaml/milestones/15/labels","id":3449103,"node_id":"MDk6TWlsZXN0b25lMzQ0OTEwMw==","number":15,"title":"4.08","description":"PRs that should be merged before the 4.08 freeze.\r\n","creator":{"login":"damiendoligez","id":19104,"node_id":"MDQ6VXNlcjE5MTA0","avatar_url":"https://avatars2.githubusercontent.com/u/19104?v=4","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":21,"closed_issues":13,"state":"open","created_at":"2018-06-25T09:47:57Z","updated_at":"2018-11-21T08:19:03Z","due_on":"2018-10-10T07:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/ocaml/ocaml/pulls/2041/commits","review_comments_url":"https://api.github.com/repos/ocaml/ocaml/pulls/2041/comments","review_comment_url":"https://api.github.com/repos/ocaml/ocaml/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ocaml/ocaml/issues/2041/comments","statuses_url":"https://api.github.com/repos/ocaml/ocaml/statuses/25353267f098157cab6621081ff5b5898dec11f0","head":{"label":"diml:refactor-construction-of-initial-env","ref":"refactor-construction-of-initial-env","sha":"25353267f098157cab6621081ff5b5898dec11f0","user":{"login":"diml","id":1251584,"node_id":"MDQ6VXNlcjEyNTE1ODQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1251584?v=4","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},"repo":{"id":17478091,"node_id":"MDEwOlJlcG9zaXRvcnkxNzQ3ODA5MQ==","name":"ocaml","full_name":"diml/ocaml","private":false,"owner":{"login":"diml","id":1251584,"node_id":"MDQ6VXNlcjEyNTE1ODQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1251584?v=4","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},"html_url":"https://github.com/diml/ocaml","description":"Read-only mirror of INRIA SVN","fork":true,"url":"https://api.github.com/repos/diml/ocaml","forks_url":"https://api.github.com/repos/diml/ocaml/forks","keys_url":"https://api.github.com/repos/diml/ocaml/keys{/key_id}","collaborators_url":"https://api.github.com/repos/diml/ocaml/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/diml/ocaml/teams","hooks_url":"https://api.github.com/repos/diml/ocaml/hooks","issue_events_url":"https://api.github.com/repos/diml/ocaml/issues/events{/number}","events_url":"https://api.github.com/repos/diml/ocaml/events","assignees_url":"https://api.github.com/repos/diml/ocaml/assignees{/user}","branches_url":"https://api.github.com/repos/diml/ocaml/branches{/branch}","tags_url":"https://api.github.com/repos/diml/ocaml/tags","blobs_url":"https://api.github.com/repos/diml/ocaml/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/diml/ocaml/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/diml/ocaml/git/refs{/sha}","trees_url":"https://api.github.com/repos/diml/ocaml/git/trees{/sha}","statuses_url":"https://api.github.com/repos/diml/ocaml/statuses/{sha}","languages_url":"https://api.github.com/repos/diml/ocaml/languages","stargazers_url":"https://api.github.com/repos/diml/ocaml/stargazers","contributors_url":"https://api.github.com/repos/diml/ocaml/contributors","subscribers_url":"https://api.github.com/repos/diml/ocaml/subscribers","subscription_url":"https://api.github.com/repos/diml/ocaml/subscription","commits_url":"https://api.github.com/repos/diml/ocaml/commits{/sha}","git_commits_url":"https://api.github.com/repos/diml/ocaml/git/commits{/sha}","comments_url":"https://api.github.com/repos/diml/ocaml/comments{/number}","issue_comment_url":"https://api.github.com/repos/diml/ocaml/issues/comments{/number}","contents_url":"https://api.github.com/repos/diml/ocaml/contents/{+path}","compare_url":"https://api.github.com/repos/diml/ocaml/compare/{base}...{head}","merges_url":"https://api.github.com/repos/diml/ocaml/merges","archive_url":"https://api.github.com/repos/diml/ocaml/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/diml/ocaml/downloads","issues_url":"https://api.github.com/repos/diml/ocaml/issues{/number}","pulls_url":"https://api.github.com/repos/diml/ocaml/pulls{/number}","milestones_url":"https://api.github.com/repos/diml/ocaml/milestones{/number}","notifications_url":"https://api.github.com/repos/diml/ocaml/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/diml/ocaml/labels{/name}","releases_url":"https://api.github.com/repos/diml/ocaml/releases{/id}","deployments_url":"https://api.github.com/repos/diml/ocaml/deployments","created_at":"2014-03-06T13:13:44Z","updated_at":"2017-12-04T13:11:52Z","pushed_at":"2018-11-13T09:37:08Z","git_url":"git://github.com/diml/ocaml.git","ssh_url":"git@github.com:diml/ocaml.git","clone_url":"https://github.com/diml/ocaml.git","svn_url":"https://github.com/diml/ocaml","homepage":null,"size":201688,"stargazers_count":0,"watchers_count":0,"language":"OCaml","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"trunk"}},"base":{"label":"ocaml:trunk","ref":"trunk","sha":"cfea1a430bcc7c37f8f372a6b48515b5e538ef09","user":{"login":"ocaml","id":1841483,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4NDE0ODM=","avatar_url":"https://avatars3.githubusercontent.com/u/1841483?v=4","gravatar_id":"","url":"https://api.github.com/users/ocaml","html_url":"https://github.com/ocaml","followers_url":"https://api.github.com/users/ocaml/followers","following_url":"https://api.github.com/users/ocaml/following{/other_user}","gists_url":"https://api.github.com/users/ocaml/gists{/gist_id}","starred_url":"https://api.github.com/users/ocaml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocaml/subscriptions","organizations_url":"https://api.github.com/users/ocaml/orgs","repos_url":"https://api.github.com/users/ocaml/repos","events_url":"https://api.github.com/users/ocaml/events{/privacy}","received_events_url":"https://api.github.com/users/ocaml/received_events","type":"Organization","site_admin":false},"repo":{"id":6786166,"node_id":"MDEwOlJlcG9zaXRvcnk2Nzg2MTY2","name":"ocaml","full_name":"ocaml/ocaml","private":false,"owner":{"login":"ocaml","id":1841483,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE4NDE0ODM=","avatar_url":"https://avatars3.githubusercontent.com/u/1841483?v=4","gravatar_id":"","url":"https://api.github.com/users/ocaml","html_url":"https://github.com/ocaml","followers_url":"https://api.github.com/users/ocaml/followers","following_url":"https://api.github.com/users/ocaml/following{/other_user}","gists_url":"https://api.github.com/users/ocaml/gists{/gist_id}","starred_url":"https://api.github.com/users/ocaml/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocaml/subscriptions","organizations_url":"https://api.github.com/users/ocaml/orgs","repos_url":"https://api.github.com/users/ocaml/repos","events_url":"https://api.github.com/users/ocaml/events{/privacy}","received_events_url":"https://api.github.com/users/ocaml/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/ocaml/ocaml","description":"The core OCaml system: compilers, runtime system, base libraries","fork":false,"url":"https://api.github.com/repos/ocaml/ocaml","forks_url":"https://api.github.com/repos/ocaml/ocaml/forks","keys_url":"https://api.github.com/repos/ocaml/ocaml/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ocaml/ocaml/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ocaml/ocaml/teams","hooks_url":"https://api.github.com/repos/ocaml/ocaml/hooks","issue_events_url":"https://api.github.com/repos/ocaml/ocaml/issues/events{/number}","events_url":"https://api.github.com/repos/ocaml/ocaml/events","assignees_url":"https://api.github.com/repos/ocaml/ocaml/assignees{/user}","branches_url":"https://api.github.com/repos/ocaml/ocaml/branches{/branch}","tags_url":"https://api.github.com/repos/ocaml/ocaml/tags","blobs_url":"https://api.github.com/repos/ocaml/ocaml/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ocaml/ocaml/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ocaml/ocaml/git/refs{/sha}","trees_url":"https://api.github.com/repos/ocaml/ocaml/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ocaml/ocaml/statuses/{sha}","languages_url":"https://api.github.com/repos/ocaml/ocaml/languages","stargazers_url":"https://api.github.com/repos/ocaml/ocaml/stargazers","contributors_url":"https://api.github.com/repos/ocaml/ocaml/contributors","subscribers_url":"https://api.github.com/repos/ocaml/ocaml/subscribers","subscription_url":"https://api.github.com/repos/ocaml/ocaml/subscription","commits_url":"https://api.github.com/repos/ocaml/ocaml/commits{/sha}","git_commits_url":"https://api.github.com/repos/ocaml/ocaml/git/commits{/sha}","comments_url":"https://api.github.com/repos/ocaml/ocaml/comments{/number}","issue_comment_url":"https://api.github.com/repos/ocaml/ocaml/issues/comments{/number}","contents_url":"https://api.github.com/repos/ocaml/ocaml/contents/{+path}","compare_url":"https://api.github.com/repos/ocaml/ocaml/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ocaml/ocaml/merges","archive_url":"https://api.github.com/repos/ocaml/ocaml/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ocaml/ocaml/downloads","issues_url":"https://api.github.com/repos/ocaml/ocaml/issues{/number}","pulls_url":"https://api.github.com/repos/ocaml/ocaml/pulls{/number}","milestones_url":"https://api.github.com/repos/ocaml/ocaml/milestones{/number}","notifications_url":"https://api.github.com/repos/ocaml/ocaml/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ocaml/ocaml/labels{/name}","releases_url":"https://api.github.com/repos/ocaml/ocaml/releases{/id}","deployments_url":"https://api.github.com/repos/ocaml/ocaml/deployments","created_at":"2012-11-20T22:18:22Z","updated_at":"2018-11-20T19:33:15Z","pushed_at":"2018-11-20T23:13:32Z","git_url":"git://github.com/ocaml/ocaml.git","ssh_url":"git@github.com:ocaml/ocaml.git","clone_url":"https://github.com/ocaml/ocaml.git","svn_url":"https://github.com/ocaml/ocaml","homepage":"","size":181510,"stargazers_count":2084,"watchers_count":2084,"language":"OCaml","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":493,"mirror_url":null,"archived":false,"open_issues_count":164,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":493,"open_issues":164,"watchers":2084,"default_branch":"trunk"}},"_links":{"self":{"href":"https://api.github.com/repos/ocaml/ocaml/pulls/2041"},"html":{"href":"https://github.com/ocaml/ocaml/pull/2041"},"issue":{"href":"https://api.github.com/repos/ocaml/ocaml/issues/2041"},"comments":{"href":"https://api.github.com/repos/ocaml/ocaml/issues/2041/comments"},"review_comments":{"href":"https://api.github.com/repos/ocaml/ocaml/pulls/2041/comments"},"review_comment":{"href":"https://api.github.com/repos/ocaml/ocaml/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ocaml/ocaml/pulls/2041/commits"},"statuses":{"href":"https://api.github.com/repos/ocaml/ocaml/statuses/25353267f098157cab6621081ff5b5898dec11f0"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"dra27"}}