1 Running Top-Level Programs
2 Installing Libraries
3 Libraries and Collections
4 Scheme Interoperability
5 R6RS Conformance
6 R6RS Libraries
Index
Version: 4.0.2

 

2 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 PLT Scheme.

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.ss" 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

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 search in order, and before the installation’s collections.