---
name: "Topfind"
section: "3"
platform: "linux"
package: "ocaml-findlib"
version: "0.6.2-4"
release: "Debian 3.0 (Woody)"
platforms: ["linux"]
url: "https://new.carta.tech/Topfind"
---

# Topfind(3)

## SIGNATURE

```
module Topfind :
  sig
    val predicates : string list ref
    val predicates : string list -> unit
    val syntax : string -> unit
    val standard_syntax : unit -> unit
    val revised_syntax : unit -> unit
    val don't_load : string list -> unit
    val don't_load_deeply : string list -> unit
    val load : string list -> unit
    val load_deeply : string list -> unit
    val reset : unit -> unit
  end
```

## DIRECTIVES

```
#require "package-name-list";;
#camlp4o ;;
#camlp4r ;;
```

## PACKAGING

The 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
options
```

The module is not thread-safe; if used in a multi-threaded script, all  packgage loading must have happened before the first thread forks.

## DESCRIPTION

The Topfind module contains some functions simplifying package loading  in scripts. Most important, there is a new directive "#require" for  the same purpose.

The 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  don't\_load   function. If the toploop has been built by  ocamlfind\[Command-line interface of the Package manager\], the necessary initialization is  automatically compiled in.

### The variable Topfind.predicates

```
val predicates : string list ref
```

The variable contains the set of predicates that is assumed when  packages are loaded.

### Topfind.add\_predicates predlist

```
val predicates : string list -> unit
```

This function adds the passed predicates  *predlist*   to the variable  predicates.

### Topfind.syntax variant

```
val syntax : string -> unit
```

This function emulates the  -syntax command line  switch of ocamlfind.

### Topfind.standard\_syntax ()

```
val standard_syntax : unit -> unit
```

The same as  syntax "camlp4o".

### Topfind.revised\_syntax ()

```
val revised_syntax : unit -> unit
```

The same as  syntax "camlp4r".

### Topfind.don't\_load pkglist

```
val don't_load : string list -> unit
```

Declares the packages enumerated in  *pkglist*   as being linked into the toploop.

### Topfind.don't\_load\_deeply pkglist

```
val don't_load_deeply : string list -> unit
```

Declares the packages enumerated in  *pkglist*   and all direct and indirect ancestors as being linked into the toploop.

### Topfind.load pkglist

```
val load : string list -> unit
```

The packages enumerated in  *pkglist* are  loaded in turn; packages that have already been loaded or that have  been declared as linked in are skipped.

### Topfind.load\_deeply pkglist

```
val load_deeply : string list -> unit
```

The packages enumerated in  *pkglist* and all  direct or indirect ancestors are loaded in topological order;  packages that have already been loaded or that have  been declared as linked in are skipped.

### Topfind.reset ()

```
val reset : unit -> unit
```

This function causes that Topfind forgets that any package has already  been loaded. Infomation about packages linked into the toploop remain  intact. The effect of this function is that all dynamically loaded  packages will be loaded again when  load,  load\_deeply functions, or the  #require directive are executed.

### #require 'package-name-list';;

```
#require "
package-name-list
";;
```

The argument of the directive is a list of package names, separated by  commas and/or whitespace. The directive has the same effect as  load\_deeply, i.e. the listed  packages and all  direct or indirect ancestors are loaded in topological order;  packages that have already been loaded or that have  been declared as linked in are skipped.

### #camlp4o ;;

```
#camlp4o ;;
```

Selects the standard syntax and loads the camlp4 preprocessor.

### #camlp4r ;;

```
#camlp4r ;;
```

Selects the revised syntax and loads the camlp4 preprocessor.
