Next: , Previous: , Up: libutils   [Index]


7.6 Loading libraries

Libraries are interned using the functions find-library-*, Interning libraries. All those functions first search the internal collection, then load libraries through the procedure referenced by the parameter current-library-loader.

The following bindings are exported by the library (vicare libraries).

Parameter: current-library-loader

Reference a function used to load a library, either source or binary, given a R6RS library reference; the referenced function must intern the library and all its dependencies. The parameter is used as follows:

((current-library-loader) ?libref)

The referenced function is meant to be called after we have checked that a compliant library is not already interned. The referenced function is allowed to return unspecified values.

Function: default-library-loader libref

Default value for the parameter current-library-loader. Given a R6RS library reference: attempt to locate the library in an external repository and load it; all the dependency libraries are interned. Return unspecified values.

This function makes use of: the library locator referenced by the parameter current-library-locator; the source library loader referenced by the parameter current-source-library-loader; the binary library loader referenced by the parameter current-binary-library-loader.

libref must be a library reference as defined by R6RS:

(?identifier0 ?identifier)
(?identifier0 ?identifier ... ?version-reference)

scheme library form import for details on library references.

Interning source libraries

Any function we set in the parameter current-library-loader can use the following API to intern a source library.

Parameter: current-source-library-loader

Reference a function used to load a source library from a textual input port.

The referenced function must accept two arguments: a R6RS library reference, a textual input port from which the source library can be read. It must: read from the port a library symbolic expression; verify that its library name conforms to the library reference; load and intern all its dependency libraries; expand it; compile it; intern it.

If successful the function must return a symbolic expression representing the R6RS library name of the loaded library; otherwise return #f.

Function: default-source-library-loader libref textual-port

Default value for the parameter current-source-library-loader. Given a textual input port:

  1. Read from it a library symbolic expression.
  2. Verify that its version reference conforms to libref.
  3. Using the expander procedure referenced by current-library-expander: load and intern all its dependency libraries; expand it; compile it; intern it.

If successful return a symbolic expression representing the R6RS library name of the loaded library; otherwise return #f.

This function assumes that applying the function port-id to textual-port will return a string representing a file name associated to the port (or equivalent).

Interning binary libraries

Any function we set in the parameter current-library-loader can use the following API to intern a binary library.

Parameter: current-binary-library-loader

Reference a function used to load a binary library.

The referenced function must accept two arguments: a R6RS library reference, a binary input port from which the serialised library can be read. It must: read from the port a serialised library; verify that its library name conforms to the library reference; intern it along with all its dependency libraries.

If successful the function must return a symbolic expression representing the R6RS library name of the interned library; otherwise return #f.

Function: default-binary-library-loader libref binary-port

Default value for the parameter current-binary-library-loader. Given a binary input port: read from it a serialised library; verify that its version reference conforms to libref; intern it along with all its dependency libraries.

If successful return a symbolic expression representing the R6RS library name of the interned library; otherwise return #f.

This function assumes that applying the function port-id to binary-port will return a string representing a file name associated to the port (or equivalent).


Next: , Previous: , Up: libutils   [Index]