SLIB is a portable library for the programming language Scheme. It provides a platform independent framework for using packages of Scheme procedures and syntax. As distributed, SLIB contains useful packages for all implementations. Its catalog can be transparently extended to accomodate packages specific to a site, implementation, user, or directory.
Aubrey Jaffer <jaffer@ai.mit.edu>
Hyperactive Software -- The Maniac Inside!
http://swissnet.ai.mit.edu/~jaffer/SLIB.html
SLIB denotes features by symbols. SLIB maintains a list of features supported by the Scheme session. The set of features provided by a session may change over time. Some features are properties of the Scheme implementation being used. The following features detail what sort of numbers are available from an implementation.
Other features correspond to the presence of sets of Scheme procedures or syntax (macros).
#t
if feature is supported by the current Scheme
session.
(provided? feature)
will return #t
.
(provided? 'foo) => #f (provide 'foo) (provided? 'foo) => #t
SLIB creates and maintains a catalog mapping features to locations of files introducing procedures and syntax denoted by those features.
At the beginning of each section of this manual, there is a line like
(require 'feature)
.
The Scheme files comprising SLIB are cataloged so that these feature
names map to the corresponding files.
SLIB provides a form, require
, which loads the files providing
the requested feature.
(provided? feature)
is true,
then require
just returns an unspecified value.
(provided? feature)
will return #t
.
The catalog can also be queried using require:feature->path
.
#t
.
#f
.
At the start of a session no catalog is present, but is created with the
first catalog inquiry (such as (require 'random)
). Several
sources of catalog information are combined to produce the catalog:
cd
to this directory before starting the
Scheme session.
Catalog files consist of one or more association lists. In the circumstance where a feature symbol appears in more than one list, the latter list's association is retrieved. Here are the supported formats for elements of catalog lists:
(feature . <symbol>)
(feature . "<path>")
(feature source "<path>")
slib:load
s the Scheme source file <path>.
(feature compiled "<path>" ...)
slib:load-compiled
s the files <path> ....
The various macro styles first require
the named macro package,
then just load <path> or load-and-macro-expand <path> as
appropriate for the implementation.
(feature defmacro "<path>")
defmacro:load
s the Scheme source file <path>.
(feature macro-by-example "<path>")
defmacro:load
s the Scheme source file <path>.
(feature macro "<path>")
macro:load
s the Scheme source file <path>.
(feature macros-that-work "<path>")
macro:load
s the Scheme source file <path>.
(feature syntax-case "<path>")
macro:load
s the Scheme source file <path>.
(feature syntactic-closures "<path>")
macro:load
s the Scheme source file <path>.
Here is an example of a `usercat' catalog. A Program in this
directory can invoke the `run' feature with (require 'run)
.
;;; "usercat": SLIB catalog additions for SIMSYNCH. -*-scheme-*- ( (simsynch . "../synch/simsynch.scm") (run . "../synch/run.scm") (schlep . "schlep.scm") )
SLIB combines the catalog information which doesn't vary per user into the file `slibcat' in the implementation-vicinity. Therefore `slibcat' needs change only when new software is installed or compiled. Because the actual pathnames of files can differ from installation to installation, SLIB builds a separate catalog for each implementation it is used with.
The definition of *SLIB-VERSION*
in SLIB file `require.scm'
is checked against the catalog association of *SLIB-VERSION*
to
ascertain when versions have changed. I recommend that the definition
of *SLIB-VERSION*
be changed whenever the library is changed. If
multiple implementations of Scheme use SLIB, remember that recompiling
one `slibcat' will fix only that implementation's catalog.
The compilation scripts of Scheme implementations which work with SLIB
can automatically trigger catalog compilation by deleting
`slibcat' or by invoking a special form of require
:
Another special form of require
erases SLIB's catalog, forcing it
to be reloaded the next time the catalog is queried.
Each file in the table below is descibed in terms of its file-system independent vicinity (see section Vicinity). The entries of a catalog in the table override those of catalogs above it in the table.
implementation-vicinity
`slibcat'
library-vicinity
`mklibcat.scm'
library-vicinity
`sitecat'
implementation-vicinity
`implcat'
implementation-vicinity
.
implementation-vicinity
`mkimpcat.scm'
implementation-vicinity
`sitecat'
home-vicinity
`homecat'
user-vicinity
`usercat'
user-vicinity
.
The procedures described in these sections are supported by all implementations as part of the `*.init' files or by `require.scm'.
require
d.
*features* must be defined by all implementations
(see section Porting).
Here are features which SLIB (`require.scm') adds to *features* when appropriate.
For each item, (provided? 'feature)
will return #t
if that feature is available, and #f
if not.
source
, or compiled
. The cdr of the pathname
should be either a string or a list.
In the following functions if the argument feature is not a symbol it is assumed to be a pathname.
#t
if feature is a member of *features*
or
*modules*
or if feature is supported by a file already
loaded and #f
otherwise.
(provided? feature)
is true
require
returns. Otherwise, if (assq feature
*catalog*)
is not #f
, the associated files will be loaded and
(provided? feature)
will henceforth return #t
. An
unspecified value is returned. If feature is not found in
*catalog*
, then an error is signaled.
require
, pathname is loaded. An
unspecified value is returned.
*features*
if
feature is a symbol and *modules*
otherwise.
#t
if feature is a member of *features*
or
*modules*
or if feature is supported by a file already
loaded. Returns a path if one was found in *catalog*
under the
feature name, and #f
otherwise. The path can either be a string
suitable as an argument to load or a pair as described above for
*catalog*.
A vicinity is a descriptor for a place in the file system. Vicinities hide from the programmer the concepts of host, volume, directory, and version. Vicinities express only the concept of a file environment where a file name can be resolved to a file in a system independent manner. Vicinities can even be used on flat file systems (which have no directory structure) by having the vicinity express constraints on the file name. On most systems a vicinity would be a string. All of these procedures are file system dependent.
These procedures are provided by all implementations.
in-vicinity
.
program-vicinity
can
return incorrect values if your program escapes back into a
load
.
home-vicinity
returns #f
.
slib:load
,
slib:load-source
, slib:load-compiled
,
open-input-file
, open-output-file
, etc. The returned
filename is filename in vicinity. in-vicinity
should
allow filename to override vicinity when filename is
an absolute pathname and vicinity is equal to the value of
(user-vicinity)
. The behavior of in-vicinity
when
filename is absolute and vicinity is not equal to the value
of (user-vicinity)
is unspecified. For most systems
in-vicinity
can be string-append
.
sub-vicinity
will
return a pathname of the subdirectory name of
vicinity.These constants and procedures describe characteristics of the Scheme and underlying operating system. They are provided by all implementations.
char->integer
.
In implementations which do not support integers of practically unlimited size, most-positive-fixnum is the largest exact integer that may result from computing the length of a list, vector, or string.
unix
, vms
, macos
, amiga
, or
ms-dos
.
(slib:report-version) => slib "2c4" on scm "5b1" on unix
(slib:report-version)
followed by
almost all the information neccessary for submitting a problem report.
An unspecified value is returned.
(slib:report) => slib "2c4" on scm "5b1" on unix (implementation-vicinity) is "/home/jaffer/scm/" (library-vicinity) is "/home/jaffer/slib/" (scheme-file-suffix) is ".scm" loaded *features* : trace alist qp sort common-list-functions macro values getopt compiled implementation *features* : bignum complex real rational inexact vicinity ed getenv tmpnam abort transcript with-file ieee-p1178 rev4-report rev4-optional-procedures hash object-hash delay eval dynamic-wind multiarg-apply multiarg/and- logical defmacro string-port source current-time record rev3-procedures rev2-procedures sun-dl string-case array dump char-ready? full-continuation system implementation *catalog* : (i/o-extensions compiled "/home/jaffer/scm/ioext.so") ...
These procedures are provided by all implementations.
#t
if the specified file exists. Otherwise, returns
#f
. If the underlying implementation does not support this
feature then #f
is always returned.
#f
is returned. Otherwise, #t
is
returned.
(tmpnam)
will return different
pathnames.
(current-output-port)
.
Returns the width of port, which defaults to
(current-output-port)
if absent. If the width cannot be
determined 79 is returned.
Returns the height of port, which defaults to
(current-output-port)
if absent. If the height cannot be
determined 24 is returned.
These procedures are provided by all implementations.
Example:
(identity 3) => 3 (identity '(foo bar)) => (foo bar) (map identity lst) == (copy-list lst)
The following procedures were present in Scheme until R4RS (see section `Language changes' in Revised(4) Scheme). They are provided by all SLIB implementations.
#t
.
#f
.
(last-pair (cons 1 2)) => (1 . 2) (last-pair '(1 2)) => (2) == (cons 2 '())
These procedures are provided by all implementations.
(slib:load-source "foo")
will
load from file `foo.scm'.
If an implementation does not support compiled code then
slib:load
will be identical to slib:load-source
.
eval
returns the value of obj evaluated in the current top
level environment. section Eval provides a more general evaluation
facility.
slib:eval-load
procedure does not affect the values returned by
current-input-port
and current-output-port
.
#t
, a success status is returned to the
system (if possible). If n is #f
a failure is returned to
the system (if possible). If n is an integer, then n is
returned to the system (if possible). If the Scheme session cannot exit
an unspecified value is returned from slib:exit
.
scm
Scheme
implementation.
(require 'feature)
. Include this line in your code prior to
using the package.
Go to the first, previous, next, last section, table of contents.