2

在我的~/.ocamlinit中,我有一些指令:

#use "topfind"
#thread
#require "core.top"

结果,每次 OCaml 顶层(即ocaml)启动时,我都会得到这堵巨大的文字墙:

        OCaml version 4.02.3

Findlib has been successfully loaded. Additional directives:
  #require "package";;      to load a package
  #list;;                   to list the available packages
  #camlp4o;;                to load camlp4 (standard syntax)
  #camlp4r;;                to load camlp4 (revised syntax)
  #predicates "p,q,...";;   to set these predicates
  Topfind.reset();;         to force that packages will be reloaded
  #thread;;                 to enable threads

/usr/lib/ocaml/threads: added to search path
/usr/lib/ocaml/unix.cma: loaded
/usr/lib/ocaml/threads/threads.cma: loaded
/usr/lib/ocaml/compiler-libs: added to search path
/usr/lib/ocaml/bigarray.cma: loaded
/home/user/.opam/system/lib/bin_prot: added to search path
/home/user/.opam/system/lib/bin_prot/bin_prot.cma: loaded
/home/user/.opam/system/lib/fieldslib: added to search path
/home/user/.opam/system/lib/fieldslib/fieldslib.cma: loaded
/usr/lib/ocaml/nums.cma: loaded
/home/user/.opam/system/lib/num-top: added to search path
/home/user/.opam/system/lib/num-top/num_top.cma: loaded
/home/user/.opam/system/lib/num: added to search path
/home/user/.opam/system/lib/sexplib: added to search path
/home/user/.opam/system/lib/sexplib/sexplib.cma: loaded
/home/user/.opam/system/lib/ppx_assert: added to search path
/home/user/.opam/system/lib/ppx_assert/ppx_assert_lib.cma: loaded
/home/user/.opam/system/lib/ppx_bench: added to search path
/home/user/.opam/system/lib/ppx_bench/ppx_bench_lib.cma: loaded
/home/user/.opam/system/lib/ppx_expect: added to search path
/home/user/.opam/system/lib/ppx_expect/expect_test_common.cma: loaded
/home/user/.opam/system/lib/ppx_expect/expect_test_config.cma: loaded
/home/user/.opam/system/lib/ppx_inline_test: added to search path
/home/user/.opam/system/lib/ppx_inline_test/inline_test_config.cma: loaded
/home/user/.opam/system/lib/ppx_inline_test/ppx_inline_test_lib.cma: loaded
/home/user/.opam/system/lib/ppx_expect/expect_test_collector.cma: loaded
/home/user/.opam/system/lib/result: added to search path
/home/user/.opam/system/lib/result/result.cma: loaded
/home/user/.opam/system/lib/typerep: added to search path
/home/user/.opam/system/lib/typerep/typerep_lib.cma: loaded
/home/user/.opam/system/lib/variantslib: added to search path
/home/user/.opam/system/lib/variantslib/variantslib.cma: loaded
/home/user/.opam/system/lib/core_kernel: added to search path
/home/user/.opam/system/lib/core_kernel/core_kernel.cma: loaded
/home/user/.opam/system/lib/sexplib/sexplib_unix.cma: loaded
/home/user/.opam/system/lib/core: added to search path
/home/user/.opam/system/lib/core/core.cma: loaded
/home/user/.opam/system/lib/core/core_top.cma: loaded
#

有没有办法在顶层启动时使模块的加载静音?

4

1 回答 1

5

trivelt 的评论有最好的答案 - 使用 utop!- 但如果您或其他人想ocaml直接使用,您可以设置Sys.interactivefalse静音大多数状态消息。例如:

嘈杂:

$ ocaml
        OCaml version 4.06.0

# #use "topfind";;
- : unit = ()
Findlib has been successfully loaded. Additional directives:
  #require "package";;      to load a package
  #list;;                   to list the available packages
  #camlp4o;;                to load camlp4 (standard syntax)
  #camlp4r;;                to load camlp4 (revised syntax)
  #predicates "p,q,...";;   to set these predicates
  Topfind.reset();;         to force that packages will be reloaded
  #thread;;                 to enable threads

- : unit = ()

更安静:

$ ocaml
        OCaml version 4.06.0

# Sys.interactive := false;;
- : unit = ()
# #use "topfind";;
- : unit = ()
- : unit = ()

如果您想自动完成这项工作,您可以放在文件Sys.interactive := false;;的开头和结尾。.ocamlinitSys.interactive := true;;

于 2018-04-04T16:03:33.357 回答