<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <link rel="stylesheet" href="style.css" type="text/css"> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type"> <link rel="Start" href="index.html"> <link rel="previous" href="Fl_metascanner.html"> <link rel="Up" href="index.html"> <link title="Index of types" rel=Appendix href="index_types.html"> <link title="Index of exceptions" rel=Appendix href="index_exceptions.html"> <link title="Index of values" rel=Appendix href="index_values.html"> <link title="Index of modules" rel=Appendix href="index_modules.html"> <link title="Findlib" rel="Chapter" href="Findlib.html"> <link title="Fl_package_base" rel="Chapter" href="Fl_package_base.html"> <link title="Fl_metascanner" rel="Chapter" href="Fl_metascanner.html"> <link title="Topfind" rel="Chapter" href="Topfind.html"><link title="Directives" rel="Section" href="#1_Directives"> <link title="Functions and variables" rel="Section" href="#1_Functionsandvariables"> <title>The Findlib Library : Topfind</title> </head> <body> <div class="navbar"><a href="Fl_metascanner.html">Previous</a> <a href="index.html">Up</a> </div> <center><h1>Module <a href="type_Topfind.html">Topfind</a></h1></center> <br> <pre><span class="keyword">module</span> Topfind: <code class="code">sig</code> <a href="Topfind.html">..</a> <code class="code">end</code></pre>Load packages from toploops and scripts <p> The <code class="code">Topfind</code> module is part of the <code class="code">findlib</code> 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. <pre><code class="code"> ocamlfind ocamlmktop ...options... -package findlib -linkpkg </code></pre> <p> 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): <pre><code class="code"> $ 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 = () # _ </code></pre> <p> This works even in scripts (but the startup message is suppressed in this case). <p> The module is not thread-safe; if used in a multi-threaded script, all packgage loading must have happened before the first thread forks. <p> The Topfind module contains some functions simplifying package loading in scripts. Most important, there is a new directive <code class="code">#require</code> for the same purpose (see below). <p> The <code class="code">Topfind</code> module needs some initialization, in particular the <code class="code">predicates</code> variable needs to be set, and the packages already compiled into the toploop needs to be declared by the <code class="code">don't_load</code> function. If the toploop has been built by <code class="code">ocamlfind</code>, the necessary initialization is automatically compiled in.<br> <hr width="100%"> <br> <a name="1_Directives"></a> <h1>Directives</h1> <p> This module also defines the following directives for the toploop: <p> <ul> <li><code class="code">#require "<package>"</code> loads the package (and if necessary the prerequisites of the package)</li> <li><code class="code">#camlp4o</code> loads camlp4 and selects standard syntax</li> <li><code class="code">#camlp4r</code> loads camlp4 and selects revised syntax</li> <li><code class="code">#list</code> lists the available packages (calls external command "ocamlfind")</li> <li><code class="code">#thread</code> enables multi-threading if possible</li> <li><code class="code">#predicates "p1,p2,..."</code> adds these predicates</li> </ul> <br> <br> <a name="1_Functionsandvariables"></a> <h1>Functions and variables</h1><br> <pre><span class="keyword">val</span> <a name="VALpredicates"></a>predicates : <code class="type">string list Pervasives.ref</code></pre><div class="info"> The list of predicates used for package loading<br> </div> <pre><span class="keyword">val</span> <a name="VALadd_predicates"></a>add_predicates : <code class="type">string list -> unit</code></pre><div class="info"> Adds predicates to the list of predicates<br> </div> <pre><span class="keyword">val</span> <a name="VALsyntax"></a>syntax : <code class="type">string -> unit</code></pre><div class="info"> Emulates the <code class="code">-syntax</code> option<br> </div> <pre><span class="keyword">val</span> <a name="VALstandard_syntax"></a>standard_syntax : <code class="type">unit -> unit</code></pre><div class="info"> Adds predicates that select the standard syntax. Same as <code class="code">syntax "camlp4o"</code><br> </div> <pre><span class="keyword">val</span> <a name="VALrevised_syntax"></a>revised_syntax : <code class="type">unit -> unit</code></pre><div class="info"> Adds predicates that select the revised syntax. Same as <code class="code">syntax "camlp4r"</code><br> </div> <pre><span class="keyword">val</span> <a name="VALdon't_load"></a>don't_load : <code class="type">string list -> unit</code></pre><div class="info"> The packages named in pkglist are added to the list of packages which are already loaded.<br> </div> <pre><span class="keyword">val</span> <a name="VALdon't_load_deeply"></a>don't_load_deeply : <code class="type">string list -> unit</code></pre><div class="info"> The packages named in pkglist and all direct and indirect ancestors are added to the list of packages which are already loaded.<br> </div> <pre><span class="keyword">val</span> <a name="VALload"></a>load : <code class="type">string list -> unit</code></pre><div class="info"> The packages from the passed package list are loaded, from left to right, but packages that have already been loaded are left out.<br> </div> <pre><span class="keyword">val</span> <a name="VALload_deeply"></a>load_deeply : <code class="type">string list -> unit</code></pre><div class="info"> 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.<br> </div> <pre><span class="keyword">val</span> <a name="VALreset"></a>reset : <code class="type">unit -> unit</code></pre><div class="info"> All entries in the list of loaded packages that have been added by <code class="code">load</code> or <code class="code">load_deeply</code> functions are removed from this list. This means that if you execute the same <code class="code">load</code> or <code class="code">load_deeply</code> functions again, the packages will be reloaded.<br> </div> <pre><span class="keyword">val</span> <a name="VALannounce"></a>announce : <code class="type">unit -> unit</code></pre><div class="info"> Output the startup message<br> </div> </body></html>