This unit has support for evaluation and macro-handling. This unit is used
by default, unless the program is compiled with the -explicit-use
option.
-
- [procedure] (load FILE [EVALPROC])
-
Loads and evaluates expressions from the given source file, which may
be either a string or an input port. Each expression read is passed to
EVALPROC (which defaults to eval). On platforms that
support it (currently Linux ELF and Solaris), load can be used
to load compiled programs:
% cat x.scm
(define (hello) (print "Hello!"))
% chicken x.scm -quiet -dynamic
% gcc x.c -shared -fPIC `chicken-config -cflags -shared -libs` -o x.so
% csi -quiet
>>> (load "x.so")
; loading x.so ...
>>> (hello)
Hello!
>>>
The second argument to load is ignored when loading compiled
code. The same compiled object file can not be loaded more than once.
If source code is loaded from a port, then that port is closed after
all expressions have been read.
- [procedure] (visit FILENAME)
-
Reads the source file FILENAME, but performs only macro-expansion.
This is mainly useful to make the macro-/syntax-, constant- and inline-function
-definitions in FILENAME available.
- [procedure] (load-library UNIT [LIBRARYFILE])
-
On platforms that support dynamic loading, load-library loads
the compiled library unit UNIT (which should be a symbol). If the
string LIBRARYFILE is given, then the given shared library will
be loaded and the toplevel code of the contained unit will be executed.
If no LIBRARYFILE argument is given, then the following libraries
are checked for the required unit:
If the unit is not found, an error is signaled. When the library unit
can be successfully loaded, a feature-identifier named UNIT
is registered. If the feature is already registered before loading,
the load-library does nothing.
- [procedure] (load-noisily FILE [EVALPROC])
-
As load but the result(s) of each evaluated toplevel-expression
is written to standard output.
- [procedure] (load-srfi-7-program FILE [EVALPROC])
-
Loads and evaluates expressions that are specified as a SRFI-7
14
configuration language program.
-
- [procedure] (repl)
-
Start a new read-eval-print loop. Sets the reset-handler so that
any invocation of reset restarts the read-eval-print loop. Also
changes the current error-handler to display a message, write
any arguments to the value of (current-error-port) and reset.
-
- [procedure] (get-line-number EXPR)
-
If EXPR is a pair with the car being a symbol, and line-number
information is available for this expression, then this procedure returns
the associated line number. If line-number information is not available,
then #f is returned. Note that line-number information for
expressions is only available in the compiler.
- [procedure] (macro? SYMBOL)
-
Returns #t if there exists a macro-definition for SYMBOL.
- [procedure] (macroexpand X)
-
If X is a macro-form, expand the macro (and repeat expansion
until expression is a non-macro form). Returns the resulting expression.
- [procedure] (macroexpand-1 X)
-
If X is a macro-form, expand the macro. Returns the resulting
expression.
- [procedure] (undefine-macro! SYMBOL)
-
Remove the current macro-definition of the macro named SYMBOL.
This functionality is only available on platforms that support dynamic
loading of compiled code. Currently Linux, BSD, Solaris and HP/UX are supported.
Note: You have to set up the extension-registry before you can use this stuff.
The easiest way is to create a directory called .chicken-registry
in your $HOME directory and run chicken-setup:
% cd $HOME
% mkdir .chicken-registry
% chicken-setup
-
- [procedure] (extension-path ID)
-
If the extension with the specifier ID is installed on the current
machine, then this procedure returns the path of the extension in the registry directory.
% chicken-setup
the registry pathname is /home/felix/.chicken-registry/REGISTRY
...
http
(http utils)
(http client)
(http server)
...
% csi -quiet
>>> (extension-path 'http)
"/home/felix/.chicken-registry/http"
>>> (extension-path '(http client))
"/home/felix/.chicken-registry/http/client"
>>> (extension-path 'foo) ; non-existant extension
#f
- [procedure] (package ID)
-
Sets the current package prefix to ID. All references
to extension IDs (as in provide, provided? and require)
are relative to this prefix.
So
(package 'foo)
(require 'bar)
is identical to
(require '(foo bar))
- [procedure] (provide ID ...)
-
Registers the extension IDs ID ... as loaded. This is mainly
intended to provide aliases for certain extension identifiers.
- [procedure] (provided? ID ...)
-
Returns #t if the extension with the IDs ID ...
are currently loaded, or #f otherwise.
Works also for feature-ids.
- [procedure] (require ID ...)
-
If the extension library ID is not already loaded into the
system, then require will lookup the location of the shared
extension library and load it. If ID names a library-unit of
the base system, then it is loaded via load-library. If no
extension library is available for the given ID, then an attempt is
made to load the file ID.so or ID.scm (in that order)
from one of the following locations:
-
the current directory
-
the current include path, which defaults to the pathnames
given in CHICKEN_INCLUDE_PATH and CHICKEN_HOME.
ID may be a symbol, or a list of symbols. See also:
require-for-syntax
-
- [procedure] (define-reader-ctor SYMBOL PROC)
-
Define new read-time constructor for #, read syntax. For further information, see
the documentation for SRFI-10 15.
-
- [procedure] (eval EXP [ENVIRONMENT])
-
Evaluates EXP and returns the result of the evaluation. The second argument is optional
and defaults to the value of (interaction-environment).