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


7.4 Interning libraries

When a library is loaded in source or binary form, it is “interned”; to intern a library means to add it to an internal collection along with all its dependency libraries. Interned libraries are neither invoked nor visited; the invoke–time and visit–time depend upon the usage we make of them.

In a Vicare process, there can be only one library with a given sequence of symbols in its name; if we have already loaded the library (a b (1)), it is not possible to load a library (a b (2)), because they have the sequence (a b) in common.

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

Function: interned-libraries
Function: interned-libraries all?

Return a list of <library> objects representing interned libraries. If all? is non–false: return all the interned libraries, else return only the visible ones.

Function: find-library-by-name libname

Given a R6RS library name: try to search and intern the corresponding library, if it is not already interned; when successful return the corresponding <library> object, otherwise raise an exception.

First search for the library among the interned ones then, if not found, in an external libraries repository using the procedure referenced by the parameter current-library-loader.

Function: find-library-by-reference libref

Given a R6RS library reference: try to search and intern the corresponding library, if it is not already interned; when successful return the corresponding <library> object, otherwise raise an exception.

First search for the library among the interned ones then, if not found, in an external libraries repository using the procedure referenced by the parameter current-library-loader.

Function: find-library-by-descriptor libdescr

Given a library descriptor, as generated by the function library-descriptor (see library-descriptor): try to search and intern the corresponding library, if it is not already interned; when successful return the corresponding <library> object, otherwise raise an exception.

First search for the library among the interned ones then, if not found, in an external libraries repository using the procedure referenced by the parameter current-library-loader.

Function: find-library-in-collection-by-predicate pred

Visit the collection of interned libraries and return the first for which pred returns non–false. If pred returns #f for all the interned libraries: return #f.

pred must be a function accepting as single argument a <library> object.

Function: find-library-in-collection-by-name libname

Given a symbolic expression representing a R6RS library name: visit the collection of interned libraries and return the first <library> object having conforming library name identifiers. If no matching library is found: return #f.

Function: find-library-in-collection-by-reference libref

Given a symbolic expression representing a R6RS library reference: visit the collection of interned libraries and return the first <library> object having conforming library name identifiers. If no matching library is found: return #f.

Function: find-library-in-collection-by-descriptor libdescr

Given a library descriptor, as generated by the function library-descriptor: visit the collection of interned libraries and return the first <library> object having the same library UID. If no matching library is found: raise an exception.

Function: unintern-library libname
Function: unintern-library libname err?

Interned libraries can be uninterned, either to free system resources or to allow reinterning from new files.

This function uninterns a library given its R6RS library name. If err? is non–false: if the library is not currently interned an exception is raised; otherwise nothing happens. Return unspecified values.

NOTE The implementation of this function is incomplete. It is to be used at the REPL when experimenting does not hurt.


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