OCaml异步编译

OCaml异步编译,ocaml,Ocaml,我有这个密码 open Async.Std;; let () = print_string "Hello World\n";; 并用 ocamlfind ocamlopt -linkpkg -package async -thread ./hello.ml stdout是空的。。。但如果代码只是 let () = print_string "Hello World\n";; 编译命令 ocamlfind ocamlopt -linkpkg -package async -thread .

我有这个密码

open Async.Std;;

let () = print_string "Hello World\n";;
并用

ocamlfind ocamlopt -linkpkg -package async -thread ./hello.ml
stdout是空的。。。但如果代码只是

let () = print_string "Hello World\n";;
编译命令

ocamlfind ocamlopt -linkpkg -package async -thread ./hello.ml

我有我的“你好世界”。我做错了什么?为什么第一个示例不起作用?

它不起作用,因为
open Async.Std
隐式重写了像
print\u string
这样的I/O函数并使它们异步。因此,在启动调度程序之前,它们不会被执行

open Async.Std

let () =
  print_string "Hello World\n";              (* schedule "Hello World\n" printing *)
  don't_wait_for (exit 0);                   (* schedule exit from the program *)
  Core.Std.never_returns (Scheduler.go ())   (* run the scheduler *)
了解有关异步的更多信息