Load packages from toploops and scripts
Topfind module is part of the
findlib package. The module
depends on the presence of a toploop. When building a toploop, it is
automatically linked in if "findlib" is linked in, e.g.
ocamlfind ocamlmktop ...options... -package findlib -linkpkg
When the platform supports DLLs, another possibility to get a toploop with findlib directives is to load the file "topfind" (normally installed in the standard library directory):
$ ocaml Objective Caml version 3.04 # #use "topfind";; 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) Topfind.reset();; to force that packages will be reloaded ~ : unit = () # _
This works even in scripts (but the startup message is suppressed in this case).
The module is not thread-safe; if used in a multi-threaded script, all packgage loading must have happened before the first thread forks.
The Topfind module contains some functions simplifying package loading
in scripts. Most important, there is a new directive
the same purpose (see below).
Topfind module needs some initialization, in particular the
predicates variable needs to be
set, and the packages already compiled into the toploop needs to be
declared by the
function. If the toploop has been built by
the necessary initialization is
automatically compiled in.
This module also defines the following directives for the toploop:
#require "<package>"loads the package (and if necessary the prerequisites of the package)
#camlp4oloads camlp4 and selects standard syntax
#camlp4rloads camlp4 and selects revised syntax
#listlists the available packages (calls external command "ocamlfind")
#threadenables multi-threading if possible
#predicates "p1,p2,..."adds these predicates
Adds predicates to the list of predicates
Adds predicates that select the standard syntax. Same as
Adds predicates that select the revised syntax. Same as
The packages named in pkglist are added to the list of packages which are already loaded.
The packages named in pkglist and all direct and indirect ancestors are added to the list of packages which are already loaded.
The packages from the passed package list are loaded, from left to right, but packages that have already been loaded are left out.
The packages from the passed package list and all direct or indirect ancestors are loaded in topological order. Packages that have already been loaded are left out.
All entries in the list of loaded packages that have been added by
load_deeply functions are removed from this list. This
means that if you execute the same
again, the packages will be reloaded.
Output the startup message