ocaml-community / utop

Universal toplevel for OCaml
Other
833 stars 110 forks source link

`#thread;;` does not always work #483

Open polytypic opened 3 months ago

polytypic commented 3 months ago

For some reason #thread;; does not always work:

────────┬─────────────────────────────────────────────────────────────┬────────
        │ Welcome to utop version 2.14.0 (using OCaml version 5.1.1)! │        
        └─────────────────────────────────────────────────────────────┘        
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

Type #utop_help for help about using utop.

─( 13:51:22 )─< command 0 >─────────────────────────────────────{ counter: 0 }─
utop # #thread;;
─( 13:51:22 )─< command 1 >─────────────────────────────────────{ counter: 0 }─
utop # Thread.create;;
Error: Unbound module Thread
─( 13:51:28 )─< command 2 >─────────────────────────────────────{ counter: 0 }─
utop # #require "threads.posix";;
─( 13:51:35 )─< command 3 >─────────────────────────────────────{ counter: 0 }─
utop # Thread.create;;
- : ('a -> 'b) -> 'a -> Thread.t = <fun>
─( 13:51:47 )─< command 4 >─────────────────────────────────────{ counter: 0 }─
utop # 

Notice how after #thread;; the Thread module is not available. However, after #require "threads.posix";; the Thread module becomes available.

The above output was produced on macOS.