3 Installing Libraries

▼ |  | R6RS: Scheme

1 | Using R6RS with Dr Racket
2 | Running Top-Level Programs
3 | Installing Libraries
4 | R6RS Module Language
5 | Libraries and Collections
6 | Language Interoperability
7 | R6RS Conformance
8 | R6RS Libraries
| Index

top contents ← prev up next →

## 3 Installing Libraries🔗ℹ

To reference an R6RS library from a top-level program or another library, it must be installed as a collection-based library in Racket.

One way to produce an R6RS installed library is to create in a collection a file that starts with #!r6rs and that contains a library form. For example, the following file might be created in a "hello.sls" file within a "examples" collection directory:

> #!r6rs
> (library (examples hello)
> (export greet)
> (import (rnrs))
> (define (greet)
> (display "hello\n")))

Alternately, the plt-r6rs executable with the --install flag accepts a sequence of library declarations and installs them into separate files in a collection directory, based on the declared name of each library:

plt-r6rs --install ‹libraries-file›

By default, libraries are installed into the user-specific collection directory (see find-user-collects-dir). The --all-users flag causes the libraries to be installed into the main installation, instead (see find-collects-dir):

plt-r6rs --install --all-users ‹libraries-file›

You may as well specify an arbitrary collections directory by using the --collections flag:

plt-r6rs --install --collections ‹directory› ‹libraries-file›

See Libraries and Collections for information on how R6RS library names are turned into collection-based module paths, which determines where the files are written. Libraries installed by plt-r6rs --install are automatically compiled to bytecode form.

One final option is to supply a ++path flag to plt-r6rs. A path added with ++path extends the set of directories that are searched to find a collection (i.e., it sets current-library-collection-paths). If ‹dir› contains "duck" and "cow" sub-directories with "duck/feather.sls" and "cow/bell.sls", and if each file is an R6RS library prefixed with #!r6rs, then plt-r6rs ++path ‹dir› directs the R6RS library references (duck feather) and (cow bell) to the files. Note that this technique does not support accessing "duck.sls" directly within ‹dir›, since the library reference (duck) is treated like (duck main) for finding the library, as explained in Libraries and Collections. Multiple paths can be provided with multiple uses of ++path; the paths are searched in order, and before the installation’s collections.

top contents ← prev up next →