The implicit open Stdlib
is done early to make it possible to shadow Stdlib’s submodule with user defined one.
The construction of the initial environment is done in essentially five steps:
- start with the predefined environment
- add the persistent modules from the standard library
- open the Stdlib module
- add the persistent modules from all other directories in the path (from the
-I
option) - open the initially opened modules provided by the
-open
flag
(see https://github.com/ocaml/ocaml/pull/9345#issuecomment-613463446 for some recent discussion).
which means that all included directory -I dir_k
have already been added to the path when the -open M_l
flags are handled.