Chapter 11. System Operations

This chapter describes operations for handling errors, interrupts, and exceptions, compilation and evaluation, controlling the operation of the system, timing and statistics, defining and setting parameters, and querying the operating system environment.

Section 11.1. Errors, Interrupts, and Exceptions

Chez Scheme defines a set of mechanisms for signaling errors and other events and for controlling the action of the Scheme system when various events occur, including errors signaled by the program or system, an interrupt from the keyboard, the expiration of an internal timer set by set-timer, a breakpoint caused by a call to break, or a request from the storage manager to initiate a garbage collection. These mechanisms are described in this section, except for the collect request mechanism, which is described in Section 12.1.

Timer, keyboard, and collect request interrupts are supported via a counter that is decremented approximately once for each call to a nonleaf procedure. (A leaf procedure is one that does not itself make any calls.) When no timer is running, this counter is set to a default value (1000 in Version 6) when a program starts or after an interrupt occurs. If a timer is set (via set-timer), the counter is set to the minimum of the default value and the number of ticks to which the timer is set. When the counter reaches zero, the system looks to see if the timer is set and has expired or if a keyboard or collect request interrupt has occurred. If so, the current procedure call is pended ("put on hold") while the appropriate interrupt handler is invoked to handle the interrupt. When (if) the interrupt handler returns, the pended call takes place. Thus, timer, keyboard, and collect request interrupts effectively occur synchronously with respect to the procedure call mechanism, and keyboard and collect request interrupts may be delayed by a number of calls equal to the default timer value.

Calls to error, warning, and break handlers occur immediately whenever the error, warning, or break is signaled.


procedure: (error symbol string object ...)
returns: does not return

The arguments to error are passed along to the current error handler (see error-handler). If the handler returns, error resets to the current café.

The default error handler uses the arguments to print a descriptive message. The symbol identifies where the error occurred, the string is a format string (see format) describing the circumstances, and the objects, if any, are additional format arguments. The first argument is ignored if it is #f instead of a symbol. After formatting and printing the message, the default error handler saves the continuation of the error (see debug) and returns.

(define slow-vector-map
 ; an allocation-intensive implementation of vector-map
  (lambda (p v)
    (unless (procedure? p)
       (error 'vector-map "~s is not a procedure" p))
    (unless (vector? v)
       (error 'vector-map "~s is not a vector" v))
    (list->vector (map p (vector->list v)))))


parameter: error-handler

The value of this parameter must be a procedure. The current error handler is called by error, which passes along its arguments. See error for a description of the default error handler. The following example shows how to install a variant of the default error handler that invokes the debugger directly (using break).

(error-handler
  (lambda (who msg . args)
    (fprintf (console-output-port)
             "~%Error~a: ~a.~%"
             (if who (format " in ~s" who) "")
             (parameterize ([print-level 3] [print-length 6])
                (apply format msg args)))
    (break)))

A quick-and-dirty alternative with similar behavior is to simply set error-handler to break.

In most cases, the error handler should simply return and allow error reset to top level. The version above will do this if the user exits normally from the break handler. The version below instead exits immediately from the Scheme process with a nonzero error status, which is especially useful when running Chez Scheme from a "make" file:

(error-handler
  (lambda (who msg . args)
    (fprintf (console-output-port)
             "~%Error~a: ~a.~%"
             (if who (format " in ~s" who) "")
             (parameterize ([print-level 3] [print-length 6])
                (apply format msg args)))
    (abort)))


procedure: (warning symbol string object ...)
returns: unspecified

The arguments to warning follow the protocol described above for error. The arguments to warning are passed to the current warning handler (see warning-handler). Unlike the default error handler, the default warning handler simply displays a message and returns.


parameter: warning-handler

The value of this parameter must be a procedure. The current warning handler is called by warning, which passes along its arguments. See warning for a description of the default warning handler. The following example shows how to install a warning handler that resets instead of continuing.

(warning-handler
  (let ([old-warning-handler (warning-handler)])
    (lambda args
      (apply old-warning-handler args)
      (reset))))

It is even simpler to turn warnings into errors with

(warning-handler (error-handler))

or

(warning-handler error)


procedure: (break symbol string object ...)
procedure: (break symbol)
procedure: (break)
returns: unspecified

The arguments to break follow the protocol described above for error. The default break handler (see break-handler) displays a message and invokes the debugger. The format string and objects may be omitted, in which case the message issued by the default break handler identifies the break using the identifying symbol but provides no more information about the break. If the identifying symbol is omitted as well, no message is generated. The default break handler returns normally if the debugger exits normally.


parameter: break-handler

The value of this parameter must be a procedure. The current break handler is called by break, which passes along its arguments. See break for a description of the default break handler. The example below shows how to disable breaks.

(break-handler (lambda args (void)))


parameter: keyboard-interrupt-handler

The value of this parameter must be a procedure. The keyboard-interrupt handler is called (with no arguments) when a keyboard interrupt occurs. The default keyboard-interrupt handler invokes the interactive debugger. If the debugger exits normally the interrupted computation is resumed. The example below shows how to install a keyboard-interrupt handler that resets without invoking the debugger.

(keyboard-interrupt-handler 
  (lambda ()
    (newline (console-output-port))
    (reset)))


procedure: (set-timer n)
returns: previous current timer value

n must be a nonnegative integer. When n is nonzero, set-timer starts an internal timer with an initial value of n. When n ticks elapse, a timer interrupt occurs, resulting in invocation of the timer interrupt handler. Each tick corresponds roughly to one nonleaf procedure call (see the introduction to this section); thus, ticks are not uniform time units but instead depend heavily on how much work is done by each procedure call.

When n is zero, set-timer turns the timer off.

The value returned in either case is the value of the timer before the call to set-timer. A return value of 0 should not be taken to imply that the timer was not on; the return value may also be 0 if the timer was just about to fire when the call to set-timer occurred.

The engine mechanism (Section 6.5) is built on top of the timer interrupt so timer interrupts should not be used with engines.


parameter: timer-interrupt-handler

The value of this parameter must be a procedure. The timer interrupt handler is called by the system when the internal timer (set by set-timer) expires. The default handler signals an error to say that the handler has not been defined; any program that uses the timer should redefine the handler before setting the timer.


procedure: (disable-interrupts)
procedure: (enable-interrupts)
returns: disable count

disable-interrupts disables the handling of interrupts, including timer, keyboard, and collect request interrupts. enable-interrupts re-enables these interrupts. The system maintains a disable count that starts at zero; when zero, interrupts are enabled. Each call to disable-interrupts increments the count, effectively disabling interrupts. Each call to enable-interrupts decrements the count, if not already zero, effectively enabling interrupts. For example, two calls to disable-interrupts followed by one call to enable-interrupts leaves interrupts disabled. Calls to enable-interrupts when the count is already zero (and interrupts are enabled) have no effect. The value returned by either procedure is the number of calls to enable-interrupts required to enable interrupts.

Great care should be exercised when using these procedures, since disabling interrupts inhibits the normal processing of keyboard interrupts, timer interrupts, and, perhaps most importantly, collect request interrupts. Since garbage collection does not happen automatically when interrupts are disabled, it is possible for the storage allocator to run out of space unnecessarily should interrupts be disabled for a long period of time.

The critical-section syntactic form should be used instead of these more primitive procedures whenever possible, since critical-section ensures that interrupts are re-enabled whenever a nonlocal exit occurs, such as when an error is handled by the default error handler.


syntax: (critical-section exp1 exp2 ...)
returns: result of the last expression

critical-section evaluates the expressions exp1 exp2 ... in sequence (as if in an implicit begin), without interruption. That is, upon entry to the critical section, interrupts are disabled, and upon exit, interrupts are re-enabled. Thus, critical-section allows the implementation of indivisible operations.

critical-section can be defined as follows.

(define-syntax critical-section
  (syntax-rules ()
    ((_ e1 e2 ...)
     (dynamic-wind
       disable-interrupts
       (lambda () e1 e2 ...)
       enable-interrupts))))

The use of dynamic-wind ensures that interrupts are disabled whenever the body of the critical-section expression is active and re-enabled whenever it is not. Since calls to disable-interrupts are counted (see the discussion under disable-interrupts and enable-interrupts above), critical-section expressions may be nested with the desired effect.


procedure: (register-signal-handler sig proc)
returns: unspecified

register-signal-handler is used to establish a signal handler for a given low-level signal. sig must be an exact integer identifying a valid signal, and proc must be a procedure that accepts one argument. See your host system's <signal.h> or documentation for a list of valid signals and their numbers. After a signal handler for a given signal has been registered, receipt of the specified signal results in a call to the handler. The handler is passed the signal number, allowing the same handler to be used for different signals while differentiating among them.

Signals handled in this fashion are treated like keyboard interrupts in that the handler is not called immediately when the signal is delivered to the process, but rather at some procedure call boundary after the signal is delivered. It is generally not a good idea, therefore, to establish handlers for memory faults, illegal instructions, and the like, since the code that causes the fault or illegal instruction will continue to execute (presumably erroneously) for some time before the handler is invoked.

register-signal-handler is supported only on Unix-based systems.

Section 11.2. Environments

Environments are first-class objects containing identifier bindings. They are similar to modules but, unlike modules, may be manipulated at run time. Environments may be provided as optional arguments to eval, expand, and the procedures that define, assign, or reference top-level values.

There are several built-in environments, and new environments can be created by copying existing environments or selected bindings from existing environments.

Environments can be mutable or immutable. A mutable environment can be extended with new bindings, its existing bindings can be modified, and its variables can be assigned. An immutable environment cannot be modified in any of these ways.


procedure: (environment? obj)
returns: #t if obj is an environment, otherwise #f

(environment? (interaction-environment)) <graphic> #t
(environment? 'interaction-environment) <graphic> #f
(environment? (copy-environment (scheme-environment))) <graphic> #t


procedure: (scheme-report-environment version)
procedure: (null-environment version)
procedure: (ieee-environment)
returns: an environment

version must be an exact integer. This integer specifies a revision of the Revised Report on Scheme, i.e., the Revisedv Report on Scheme for version v.

scheme-report-environment returns an environment that is empty except for all bindings defined in the specified report that are either required or both optional and supported by the implementation. null-environment returns an environment that is empty except for the bindings for all syntactic keywords defined in the specified report that are either required or both optional and supported by the implementation. (Chez Scheme supports all optional bindings as well as required bindings.) ieee-environment returns an environment that is empty except for all bindings defined in the ANSI/IEEE Scheme standard.

scheme-report-environment and null-environment must accept the value of version that corresponds to the most recent Revised Report that the implementation claims to support, starting with the Revised5 Report. They may also accept other values of version. An error is signaled if the implementation does not support the given version.

The environments returned by these procedures are immutable.

(eval 'cons (scheme-report-environment 5)) <graphic> #<procedure cons>
(eval 'fx+ (scheme-report-environment 5)) <graphic> error


procedure: (scheme-environment)
returns: an environment

scheme-environment returns an environment containing the initial top-level bindings. This environment corresponds to the scheme module.

The environment returned by this procedure is immutable.

(set! cons 3)
(top-level-value 'cons (scheme-environment)) <graphic> #<procedure cons>
(set-top-level-value! 'cons 3 (scheme-environment)) <graphic> error


parameter: interaction-environment

The original value of interaction-environment is the default top-level environment. It is initially set to a mutable copy of (scheme-environment) and which may be extended or otherwise altered by top-level definitions and assignments. It may be set to any environment, mutable or not, to change the default top-level evaluation environment.

An expression's top-level bindings resolve to the environment that is in effect when the expression is expanded, and changing the value of this parameter has no effect on running code. Changes affect only code that is subsequently expanded, e.g., as the result of a call to eval, load, or compile-file.

(set! cons 3)
cons <graphic> 3
(top-level-value 'cons (interaction-environment)) <graphic> 3

(interaction-environment (scheme-environment))
cons <graphic> #<procedure cons>
(set! cons 3) <graphic> error
(define cons 3) <graphic> error

The standard Scheme version of interaction-environments accepts only zero arguments, i.e., it cannot be used to change the interaction environment.


procedure: (copy-environment env)
procedure: (copy-environment env mutable?)
procedure: (copy-environment env mutable? syms)
returns: a new environment

copy-environment returns a copy of env, i.e., a new environment that contains the same bindings as env.

The environment is mutable if mutable? is omitted or true; if mutable? is false, the environment is immutable.

The set of bindings copied from env to the new environment is determined by syms, which defaults to the value of (environment-symbols env). The binding, if any, for each element of syms is copied to the new environment, and no other bindings are present in the new environment.

In the current implementation, the storage space used by an environment is never collected, so repeated use of copy-environment will eventually cause the system to run out of memory.

(define e (copy-environment (scheme-environment)))
(eval '(define cons +) e)
(eval '(cons 3 4) e)                    <graphic> 7
(eval '(cons 3 4) (scheme-environment)) <graphic> (3 . 4)


procedure: (environment-symbols env)
returns: a list of symbols

This procedure returns a list of symbols representing the identifiers bound in environment env. It is primarily useful in building the list of symbols to be copied from one environment to another.

(define listless-environment
  (copy-environment
    (scheme-environment)
    #t
    (remq 'list (environment-symbols (scheme-environment)))))
(eval '(let ((x (cons 3 4))) x) listless-environment) <graphic> (3 . 4)
(eval '(list 3 4) listless-environment) <graphic> error


procedure: (apropos-list s)
procedure: (apropos-list s env)
returns: a list of symbols

This procedure returns a selected list of symbols representing identifiers bound in environment env. If s is a string, only those whose names have s as a substring are selected, and if s is a symbol, only those whose names have the name of s as a substring are selected. If no environment is provided, it defaults to value of interaction-environment.

(apropos-list 'car) <graphic> (car set-car!)

(define cartoon)
(apropos-list 'car) <graphic> (car cartoon set-car!)

(apropos-list 'car (scheme-environment)) <graphic> (car set-car!)


procedure: (apropos s)
procedure: (apropos s env)
returns: unspecified

apropos is like apropos-list except the set of selected names is displayed to the current output port.

Section 11.3. Compilation, Evaluation, and Loading


procedure: (eval obj)
procedure: (eval obj env)
returns: value of the Scheme form represented by obj

eval treats obj as the representation of an expression. It evaluates the expression in environment env and returns its value. If no environment is provided, it defaults to the environment returned by interaction-environment.

Single-argument eval is a Chez Scheme extension. Chez Scheme also permits obj to be the representation of a nonexpression form, i.e., a definition, whenever the environment is mutable.

In Chez Scheme, eval is actually a wrapper that simply passes its arguments to the current evaluator. (See current-eval.) The default evaluator is compile, which expands the expression via the current expander (see current-expand), compiles it, executes the resulting code, and returns its value. If the environment argument, env, is present, compile passes it along to the current expander, which is sc-expand by default.


parameter: current-eval

current-eval determines the evaluation procedure used by the procedures eval, load, and new-cafe. current-eval is initially bound to the value of compile. It should expect one or two arguments: an object to evaluate and an optional environment.

(current-eval interpret)
(+ 1 1) <graphic> 2

(current-eval (lambda (x . ignore) x))
(+ 1 1) <graphic> (+ 1 1)


procedure: (compile obj)
procedure: (compile obj env)
returns: value of the Scheme form represented by obj

obj is treated as a Scheme expression, expanded with the current expander (the value of current-expand) in the specified environment (or the interaction environment, if no environment is provided), compiled to machine code, and executed. compile is the default value of the current-eval parameter.


procedure: (interpret obj)
procedure: (interpret obj env)
returns: value of the Scheme form represented by obj

interpret is like compile, except that the expression is interpreted rather than compiled. interpret may be used as a replacement for compile, with the following caveats:

interpreter is often faster than compile when the form to be evaluated is short running, since it has less preevaluation overhead.


procedure: (load filename)
procedure: (load filename eval-proc)
returns: unspecified

filename must be a string. load reads and evaluates the contents of the file specified by filename. The file may contain source or object code or a mixture of both. By default, load employs eval to evaluate each source expression found in the file. If eval-proc is specified, load uses this procedure instead. eval-proc must accept one argument, the expression to evaluate.

The eval-proc argument facilitates the implementation of embedded Scheme-like languages and the use of alternate evaluation mechanisms to be used for Scheme programs. eval-proc can be put to other uses as well. For example, (load "myfile.ss" pretty-print) pretty-prints the contents of the file "myfile.ss" to the screen, and

(load "myfile.ss"
  (lambda (x)
    (write x)
    (newline)
    (eval x)))

writes each expression before evaluating it.

The parameter source-directories (Section 11.4) determines the set of directories searched for source files not identified by absolute path names.


procedure: (visit filename)
returns: unspecified

filename must be a string. visit reads the named file looking for compiled object code, and runs those portions of the compiled object code that establish compile-time information or correspond to expressions identified as "visit" time by eval-when forms contained in the original source file. Source expressions contained within the file are ignored, so it is possible to apply visit to a file containing only source code (in which case the file is read but not processed) or a combination of source and object code.

For example, if the file t1.ss contains the following forms:

(define-syntax a (identifier-syntax 3))
(module m (x) (define x 4))
(define y 5)

applying load to t1.ss has the effect of defining a, m, and y, whereas applying visit to t1.ss has no effect.

If t1.ss is compiled to t1.so, applying load to t1.so again has the effect of defining all three identifiers. Applying visit to t1.so, however, has the effect of installing the transformer for a, installing the interface for m (for use by import), and recording y as a variable. visit is useful when separately compiling one file that depends on bindings defined in another without actually loading and evaluating the code in the supporting file.

The parameter source-directories (Section 11.4) determines the set of directories searched for source files not identified by absolute path names.


procedure: (revisit filename)
returns: unspecified

filename must be a string. revisit reads the named file looking for compiled object code and runs those portions of the compiled object code that establish run-time or correspond to expressions identified as "revisit" time by eval-when forms contained in the original source file. Source expressions contained within the file are ignored, so it is possible to apply revisit to a file containing only source code (in which case the file is read but not processed) or a combination of source and object code.

Continuing the example given for visit above, applying revisit to the source file, t1.ss, has no effect. Applying revisit to the object file, t1.so, has the effect of establishing the values of the variable x exported from m and the top-level variable y, without installing either the interface for m or the transformer for a.

revisit is useful for loading compiled application code without loading unnecessary compile-time information. Care must be taken when using this feature if the application calls eval or uses top-level-value or set-top-level-value to access top-level bindings at run-time, since these procedures use compile-time information to resolve top-level bindings.

The parameter source-directories (Section 11.4) determines the set of directories searched for source files not identified by absolute path names.


procedure: (compile-file input-filename)
procedure: (compile-file input-filename output-filename)
procedure: (compile-file input-filename output-filename machine-type)
returns: unspecified

input-filename and output-filename must be strings, and machine-type must be a valid machine-type specifier.

The normal evaluation process proceeds in two steps: compilation and execution. compile-file performs the compilation process for an entire source file, producing an object file. When the object file is subsequently loaded (see load), the compilation process is not necessary, and the file typically loads several times faster.

If the optional output-filename argument is omitted, an extension of ".ss" is assumed for the input (source) filename input-filename, and this extension is replaced by an extension of ".so" in the output (object) filename. In this case, the input filename may be entered with or without the ".ss" extension. If the optional output-filename argument is specified, the file names are used exactly as specified. For example, (compile-file "myfile") produces an object file with the name "myfile.so" from the source file named "myfile.ss", while (compile-file "myfile1" "myfile2") produces an object file with the name "myfile2" from the source file name "myfile1".

By default, compile-file produces code for the current machine type (see machine-type). compile-file can be used to generate object code for another machine type, however, by specifying a different machine type, if the assembler for that machine type has been loaded.


procedure: (compile-script input-filename)
procedure: (compile-script input-filename output-filename)
procedure: (compile-script input-filename output-filename machine-type)
returns: unspecified

input-filename and output-filename must be strings, and machine-type must be a valid machine-type specifier.

compile-script is like compile-file but differs in that it copies the leading #! line from the source-file script into the object file. It also disables compression, as if the parameter compile-compressed were set to false. This permits compiled script files to be created from source script files for improved efficiency.


procedure: (compile-port input-port output-port)
procedure: (compile-port input-port output-port machine-type)
returns: unspecified

compile-port is like compile-file except that it takes input from an arbitrary input port and sends output to an arbitrary output port. Neither port is closed automatically after compilation; it is assumed that the program that opens the ports and invokes compile-port will take care of closing the ports.


procedure: (make-boot-header output-filename base-boot1 base-boot2...)
returns: unspecified

Boot files consist of a boot header followed by ordinary object code. When a boot file representing an application is loaded at system start-up time (see Section 2.5), the boot header identifies a base boot file upon which the application directly depends, or possibly two or more alternatives upon which the application can be run. make-boot-header writes a boot header to the file named by the string output-filename and identifies boot-file1 bootfile2 ..., which must be strings naming boot files, as the set of boot files upon which the current boot file depends. See Section 2.8 for more information on boot files and the use of make-boot-header.


procedure: (machine-type)
returns: the current machine type

The value returned by machine-type may be used as the third argument to compile-file. Consult the online documentation distributed with the Chez Scheme software for information on valid machine types.


procedure: (expand obj)
procedure: (expand obj env)
returns: expansion of the Scheme form represented by obj

expand treats obj as the representation of an expression. It expands the expression in environment env and returns an object representing the expanded form. If no environment is provided, it defaults to the environment returned by interaction-environment.

expand actually passes its arguments to the current expander (see current-expand), initially sc-expand.


parameter: current-expand

current-expand determines the expansion procedure used by the compiler, interpreter, and direct calls to expand to expand syntactic extensions. current-expand is initially bound to the value of sc-expand.

current-expand may be set to eps-expand to enable support for the older expansion-passing-style macros. It may be set to other procedures as well, but since the format of expanded code expected by the compiler and interpreter is not publicly documented, only sc-expand and eps-expand produce correct output.


procedure: (sc-expand obj)
procedure: (sc-expand obj env)
procedure: (eps-expand obj)
procedure: (eps-expand obj env)
procedure: (eps-expand-once obj)
procedure: (eps-expand-once obj env)
returns: the expanded form of obj

The procedure sc-expand is used to expand programs written using syntax-case macros. sc-expand is the default expander, i.e., the initial value of current-expand. obj represents the program to be expanded, and env must be an environment. If not provided, env defaults to the environment returned by interaction-environment.

eps-expand is used to expand programs that use the older expansion-passing style macros. (See Section 15.2.) eps-expand-once is used to expand expansion-passing-style macro calls one level only. The eps expander does not support any environments other than the original value of interaction-environment.


syntax: (eval-when situations form1 form2 ...)
returns: see below

situations must be a list containing some combination of the symbols eval, compile, load, visit, and revisit.

When source files are loaded (see load), the forms in the file are read, compiled, and executed sequentially, so that each form in the file is fully evaluated before the next one is read. When a source file is compiled (see compile-file), however, the forms are read and compiled, but not executed, in sequence. This distinction matters only when the execution of one form in the file affects the compilation of later forms, e.g., when the form results in the definition of a module or syntactic form or sets a compilation parameter such as optimize-level or case-sensitive.

For example, assume that a file contains the following two forms:

(define-syntax reverse-define
  (syntax-rules ()
    ((_ v x) (define x v))))

(reverse-define 3 three)

Loading this from source has the effect of defining reverse-define as a syntactic form and binding the identifier three to 3. The situation may be different if the file is compiled with compile-file, however. Unless the system or programmer takes steps to assure that the first form is fully executed before the second expression is compiled, the syntax expander will not recognize reverse-define as a syntactic form and will generate code for a procedure call to reverse-define instead of generating code to define three to be 3. When the object file is subsequently loaded, the attempt to reference either reverse-define or three will fail.

As it happens, when a define-syntax, module, import, or import-only form appears at top level, as in the example above, the compiler does indeed arrange to evaluate it before going on to compile the remainder of the file. If the compiler encounters a variable definition for an identifier that was previously something else, it records that fact as well. The compiler also generates the appropriate code so that the bindings will be present as well when the object file is subsequently loaded. This solves most, but not all, problems of this nature, since most are related to the use of define-syntax and modules. Some problems are not so straightforwardly handled, however. For example, assume that the file contains the following definitions for and .

(define nodups?
  (lambda (ids)
    (define bound-id-member?
      (lambda (id ids)
        (and (not (null? ids))
             (or (bound-identifier=? id (car ids))
                 (bound-id-member? id (cdr ids))))))
    (or (null? ids)
        (and (not (bound-id-member? (car ids) (cdr ids)))
             (nodups? (cdr ids))))))

(define-syntax mvlet
  (lambda (x)
    (syntax-case x ()
      [(_ ((x ...) mvexp) e1 e2 ...)
       (and (andmap identifier? #'(x ...))
            (nodups? #'(x ...)))
       #'(call-with-values
           (lambda () mvexp)
           (lambda (x ...) e1 e2 ...))])))

(mvlet ((a b c) (values 1 2 3))
  (list (* a a) (* b b) (* c c)))

When loaded directly, this results in the definition of nodups? as a procedure and mvlet as a syntactic abstraction before evaluation of the mvlet expression. Because nodups? is defined before the mvlet expression is expanded, the call to nodups? during the expansion of mvlet causes no difficulty. If instead this file were compiled, using compile-file, the compiler would arrange to define mvlet before continuing with the expansion and evaluation of the mvlet expression, but it would not arrange to define nodups?. Thus the expansion of the mvlet expression would fails.

In this case it does not help to evaluate the syntactic extension alone. A solution in this case would be to move the definition of nodups? inside the definition for mvlet, just as the definition for bound-id-member? is placed within nodups?, but this does not work for help routines shared among several syntactic definitions. Another solution is to label the nodups? definition a "meta" definition (see Section 10.7) but this does not work for helpers that are used both by syntactic abstractions and by run-time code.

A somewhat simpler problem occurs when setting parameters that affect compilation, such as optimize-level and case-sensitive?. If not set prior to compilation, their settings usually will not have the desired effect.

eval-when offers a solution to these problems by allowing the programmer to explicitly control what forms should or should not be evaluated during compilation. eval-when is a syntactic form and is handled directly by the expander. The action of eval-when depends upon the situations argument and whether or not the forms form1 form2 ... are being compiled via compile-file or are being evaluated directly. Let's consider each of the possible situation specifiers eval, compile, load, visit, and revisit in turn.

eval:
The eval specifier is relevant only when the eval-when form is being evaluated directly, i.e., if it is typed at the keyboard or loaded from a source file. Its presence causes form1 form2 ... to be expanded and this expansion to be included in the expansion of the eval-when form. Thus, the forms will be evaluated directly as if not contained within an eval-when form.

compile:
The compile specifier is relevant only when the eval-when form appears in a file currently being compiled. (Its presence is simply ignored otherwise.) Its presence forces form1 form2 ... to be expanded and evaluated immediately.

load:
The load specifier is also relevant only when the eval-when form appears in a file currently being compiled. Its presence causes form1 form2 ... to be expanded and this expansion to be included in the expansion of the eval-when form. Any code necessary to record binding information and evaluate syntax transformers for definitions contained in the forms is marked for execution when the file is "visited," and any code necessary to compute the values of variable definitions and the expressions contained within the forms is marked for execution when the file is "revisited." subsequently loaded.

visit:
The visit specifier is also relevant only when the eval-when form appears in a file currently being compiled. Its presence causes form1 form2 ... to be expanded and this expansion to be included in the expansion of the eval-when form, with an annotation that the forms are to be executed when the file is "visited."

revisit:
The revisit specifier is also relevant only when the eval-when form appears in a file currently being compiled. Its presence causes form1 form2 ... to be expanded and this expansion to be included in the expansion of the eval-when form, with an annotation that the forms are to be executed when the file is "revisited."

A file is considered "visited" when it is brought in by either load or visit and "revisited" when it is brought in by either load or revisit.

Top-level expressions are treated as if they are wrapped in an eval-when with situations load and eval. This means that, by default, forms typed at the keyboard or loaded from a source file are evaluated, and forms appearing in a file to be compiled are not evaluated directly but are compiled for execution when the resulting object file is subsequently loaded.

The treatment of top-level definitions is slightly more involved. All definitions result in changes to the compile-time environment. For example, an identifier defined by define is recorded as a variable, and an identifier defined by define-syntax is recorded as a keyword and associated with the value of its right-hand-side (transformer) expression. These changes are made at eval, compile, and load time as if the definitions were wrapped in an eval-when with situations eval, load, and compile. (This behavior can be altered by changing the value of the parameter eval-syntax-expanders-when.) Some definitions also result in changes to the run-time environment. For example, a variable is associated with the value of its right-hand-side expression. These changes are made just at evaluation and load time as if the definitions were wrapped in an eval-when with situations eval and load.

The treatment of local expressions or definitions (those not at top level) that are wrapped in an eval-when depends only upon whether the situation eval is present in the list of situations. If the situation eval is present, the definitions and expressions are evaluated as if they were not wrapped in an eval-when form, i.e., the eval-when form is treated as a begin form. If the situation eval is not present, the forms are ignored; in a definition context, the eval-when form is treated as an empty begin, and in an expression context, the eval-when form is treated as a constant with an unspecified value.

Since top-level syntax bindings are established, by default, at compile time as well as eval and load time, top-level variable bindings needed by syntax transformers should be wrapped in an eval-when form with situations compile, load, and eval. We can thus nodups? problem above by enclosing the definition of nodups? in an eval-when as follows.

(eval-when (compile load eval)
  (define nodups?
    (lambda (ids)
      (define bound-id-member?
        (lambda (id ids)
          (and (not (null? ids))
               (or (bound-identifier=? id (car ids))
                   (bound-id-member? id (cdr ids))))))
      (or (null? ids)
          (and (not (bound-id-member? (car ids) (cdr ids)))
               (nodups? (cdr ids)))))))

This forces it to be evaluated before it is needed during the expansion of the mvlet expression.

Just as it is useful to add compile to the default load and eval situations, omitting options is also useful. Omitting one or more of compile, load, and eval has the effect of preventing the evaluation at the given time. Omitting all of the options has the effect of inhibiting evaluation altogether.

One common combination of situations is (compile eval), which by the inclusion of compile causes the expression to be evaluated at compile time, and by the omission of load inhibits the generation of code by the compiler for execution when the file is subsequently loaded. This is typically used for the definition of syntactic extensions used only within the file in which they appear; in this case their presence in the object file is not necessary. It is also used to set compilation parameters that are intended to be in effect whether the file is loaded from source or compiled via compile-file

(eval-when (compile eval) (case-sensitive #t))

Another common situations list is (compile), which might be used to set compilation options to be used only when the file is compiled via compile-file.

(eval-when (compile) (optimize-level 3))

Finally, one other common combination is (load eval), which might be useful for inhibiting the double evaluation (during the compilation of a file and again when the resulting object file is loaded) of syntax definitions when the syntactic extensions are not needed within the file in which their definitions appear.

The behavior of eval-when is usually intuitive but can be understood precisely as follows. The syntax-case expander, which handles eval-when forms, maintains two state sets, one for compile-time forms and one for run-time forms. The set of possible states in each set are "L" for load, "C" for compile, "V" for visit, "R" for revisit, and "E" for eval.

When compiling a file, the compile-time set initially contains "L" and "C" and the run-time set initially contains only "L." When not compiling a file (as when a form is evaluated by the read-eval-print loop or loaded from a source file), both sets initially contain only "E." The subforms of an eval-when form at top level are expanded with new compile- and run-time sets determined by the current sets and the situations listed in the eval-when form. Each element of the current set contributes zero or more elements to the new set depending upon the given situations according to the following table.

load   compile   visit   revisit   eval
L L C V R ---
C --- --- --- --- C
V V C V --- ---
R R C --- R ---
E --- --- --- --- E

For example, if the current compile-time state set is {L} and the situations are load and compile, the new compile-time state set is {L, C}, since L/load contributes "L" and L/compile contributes "C."

The state sets determine how forms are treated by the expander. Compile-time forms such as syntax definitions are evaluated at a time or times determined by the compile-time state set, and run-time forms are evaluated at a time or times determined by the run-time state set. A form is evaluated immediately if "C" is in the state set. Code is generated to evaluate the form at visit or revisit time if `V" or "R" is present. If "L" is present in the compile-time set, it is treated as "V;" likewise, if "L" is present in the run-time set, it is treated as "R." If more than one of states is present in the state set, the form is evaluated at each specified time.

"E" can appear in the state set only when not compiling a file, i.e., when the expander is invoked from an evaluator such as compile or interpret. When it does appear, the expanded form is returned from the expander to be processed by the evaluator, e.g., compile or interpret, that invoked the expander.

The value of the parameter eval-syntax-expanders-when actually determines the initial compile-time state set. The parameter is bound to a list of situations, which defaults to (compile load eval). When compiling a file, compile contributes "C" to the state set, load contributes "L," visit contributes "V," revisit contributes "R," and eval contributes nothing. When not compiling a file, eval contributes "E" to the state set, and the other situations contribute nothing. There is no corresponding parameter for controlling the initial value of the run-time state set.


syntax: eval-syntax-expanders-when

This parameter must be set to a list representing a set of eval-when situations, e.g., a list containing at most one occurrence of each of the symbols eval, compile, load, visit, and revisit. It is used to determine the evaluation time of syntax definitions, module forms, and import forms are expanded. (See the discussion of eval-when above.) The default value is (compile load eval), which causes compile-time information in a file to be established when the file is loaded from source, when it is compiled via compile-file, and when a compiled version of the file is loaded via load or visit.

Section 11.4. Source directories and files


parameter: source-directories

The value of source-directories must be a list of strings, each of which names a directory path. source-directories determines the set of directories searched for source files when a file is loaded via load, include, visit, or revisit, when a syntax error occurs, or when a source file is opened in the interactive inspector.

The default value is the list ("."), which means source files will be found only in the current directory.


procedure: (with-source-path who name proc)

The procedure with-source-path searches through the current source-directories path, in order, for a file with the specified name and invokes p on the result. If no such file is found, an error is signaled with who as the first argument to error.

If name is an absolute pathname or one beginning with ./ (or .\ under Windows) or ../ (or ..\ under Windows), or if the list of source directories contains only ".", the default, or "", which is equivalent to ".", no searching is performed and name is returned.

who must be a symbol, name must be a string, and p must be a procedure that accepts one argument.

The following examples assumes that the file "pie" exists in the directory "../spam" but not in "../ham" or the current directory.

(define find-file
  (lambda (fn)
    (with-source-path 'find-file fn values)))

(find-file "pie") <graphic> "pie"

(source-directories '("." "../ham"))
(find-file "pie") <graphic> error in find-file: pie not found

(source-directories '("." "../spam"))
(find-file "pie") <graphic> "../spam/pie"

(source-directories '("." "../ham"))
(find-file "/pie") <graphic> "/pie"

(source-directories '("." "../ham"))
(find-file "./pie") <graphic> "./pie"

(source-directories '("." "../spam"))
(find-file "../pie") <graphic> "../ham/pie"

Section 11.5. Compiler Controls


parameter: optimize-level

Chez Scheme provides four levels of optimization, selectable by changing the value of the parameter optimize-level. The parameter can take on one of the four values

0:
(the default) partial optimization, no inlining, fully safe;
1:
full optimization, no inlining, fully safe;
2:
full optimization, primitives inlined, fully safe; and
3:
full optimization, primitives inlined, unsafe.

At level 0, the compiler attempts to perform simple optimizations only in order to minimize compilation time. Code generated by the compiler at level 0 performs full type and bounds checking. At level 1, the compiler attempts to perform more optimizations (with full type and bounds checking), but does not inline system primitives so that tracing or redefining, for example, car will have the desired effect. At level 2, the compiler assumes that any system primitive referenced in the code will never be redefined, and it may choose to generate more efficient inline code (with full type and bounds checking) for the primitive. At level 3, the compiler makes the same assumptions as at level 2 and may choose to generate even more efficient, but unsafe (that is, without full type and bounds checking), inline code for any system primitive.

Because primitives are inlined at optimize levels 2 and 3, the compiler issues warnings about assignments to variables that name system primitives within code compiled at these levels.

The most common way to use optimize levels is on a per-file basis, using eval-when to force the use of a particular optimize level at compile time. For example, placing:

(eval-when (compile) (optimize-level 2))

at the front of a file will cause all of the forms in the file to be compiled at optimize level 2 when the file is compiled (using compile-file) but does not affect the optimize level used when the file is loaded from source. Since compile-file parameterizes optimize-level (see parameterize), the above expression does not permanently alter the optimize level in the system in which the compile-file is performed.

Optimization level 3 should be used with caution and only on small sections of well-tested code that must run as quickly as possible. Without type and bounds checking, it is possible to corrupt the Scheme heap, something that often results in strange behavior far removed from the source of the problem.


syntax: (\#primitive variable)
syntax: #%variable
syntax: (\#primitive 2 variable)
syntax: #2%variable
syntax: (\#primitive 3 variable)
syntax: #3%variable
returns: the primitive value for variable

variable must name a primitive procedure. The \#primitive syntactic form allows control over the optimize level at the granularity of individual primitive references, and it can be used to access the original value of a primitive, regardless of the lexical context or the current top-level binding for the variable originally bound to the primitive.

Since printed variable names cannot start with the character "#", it is necessary to prepend a slash to the name of this syntactic keyword, e.g., \#primitive, or to enclose the name in vertical bars, e.g., |#primitive|.

The expression (\#primitive symbol) may be abbreviated as #%symbol. The reader expands #% followed by an object into a \#primitive expression, much as it expands 'object into a quote expression.

If a 2 or 3 appears in the form or between the # and % in the abbreviated form, the compiler treats an application of the primitive as if it were compiled at the corresponding optimize level (see the optimize-level parameter). If no number appears in the form, an the application of the primitive is treated as an optimize-level 3 application if the current optimize level is 3; otherwise, it is treated as an optimize-level 2 application.

(#%car '(a b c)) <graphic> a
(let ([car cdr]) (car '(a b c))) <graphic> (b c)
(let ([car cdr]) (#%car '(a b c))) <graphic> a
(begin (set! car cdr) (#%car '(a b c))) <graphic> a


parameter: generate-interrupt-trap

To support interrupts, including keyboard, timer, and collect request interrupts, the compiler inserts a short sequence of instructions at the entry to each nonleaf procedure. (See the introduction to Section 11.1.) This small overhead may be eliminated by setting generate-interrupt-trap to #f. The default value of this parameter is #t.

It is rarely a good idea to compile code without interrupt trap generation, since a tight loop in the generated code may completely prevent interrupts from being serviced, including the collect request interrupt that causes garbage collections to occur automatically. Disabling trap generation may be useful, however, for routines that act simply as "wrappers" for other routines for which code is presumably generated with interrupt trap generation enabled. It may also be useful for short performance-critical routines with embedded loops or recursions that are known to be short running and that make no other calls.


parameter: compile-interpret-simple

At all optimize levels, when the value of compile-interpret-simple is set to a true value (the default), compile interprets simple expressions. A simple expression is one that creates no procedures. This can save a significant amount of time over the course of many calls to compile or eval (with current-eval set to compile, its default value). When set to false, compile compiles all expressions.


parameter: generate-inspector-information

When this parameter is set to a true value (the default), information about the source and contents of procedures and continuations is generated during compilation and retained in tables associated with each code segment. This information allows the inspector to provide more complete information, at the expense of using more memory and producing larger object files (via compile-file). Although compilation and loading may be slower when inspector information is generated, the speed of the compiled code is not affected. If this parameter is changed during the compilation of a file, the original value will be restored. For example, if:

(eval-when (compile) (generate-inspector-information #f))

is included in a file, generation of inspector information will be disabled only for the remainder of that particular file.


parameter: compile-compressed

When this parameter is set to true, the default, object files produced by compile-file and compile-port are compressed.


parameter: run-cp0
parameter: cp0-effort-limit
parameter: cp0-score-limit
parameter: cp0-outer-unroll-limit

These parameters control the operation of cp0, a source optimization pass that runs after macro expansion and prior to most other compiler passes. cp0 performs procedure inlining, in which the code of one procedure is inlined at points where it is called by other procedures, as well as copy propagation, constant folding, useless code elimination, and several related optimizations. The algorithm used by the optimizer is described in detail in the paper "Fast and effective procedure inlining" [25].

The value of run-cp0 must be a procedure. Whenever the compiler is invoked on a Scheme form, the value p of this parameter is called to determine whether and how cp0 is run. p receives two arguments: cp0, the entry point into cp0, and x, the form being compiled. The default value of run-cp0 simply invokes cp0 on x:

(run-cp0 (lambda (cp0 x) (cp0 x)))

Interesting variants include

(run-cp0 (lambda (cp0 x) x))

which bypasses cp0, and

(run-cp0 (lambda (cp0 x) (cp0 (cp0 x))))

which runs cp0 twice, which can result in some improvement in the generated code but obviously costs more than running it once. A more complex example is the following

(run-cp0
  (lambda (cp0 x)
    (let ((x (cp0 x)))
      (parameterize ((cp0-effort-limit 0))
        (cp0 x)))))

which runs cp0 a second time with inlining effectively disabled. This can be valuable, since inlining can sometimes produce opportunities for other optimizations that are not detected during a single cp0 pass.

The parameters cp0-effort-limit and cp0-score-limit must be set to nonnegative fixnum values. The value of cp0-effort-limit determines the maximum amount effort spent on each inlining attempt. The time spent optimizing a program is a linear function of this limit and the number of calls in the program's source, so small values for this parameter enforce a tighter bound on compile time. The value of cp0-score-limit determines the maximum amount of code produced per inlining attempt. Small values for this parameter limit the amount of overall code expansion.

The parameter cp0-outer-unroll-limit controls the amount of inlining performed by the optimizer for recursive procedures. With the parameter's value set to the default value of 0, recursive procedures are not inlined. A nonzero value for the outer unroll limit allows calls external to a recursive procedure to be inlined. For example, the expression

(letrec ((fact (lambda (x) (if (zero? x) 1 (* x (fact (- x 1)))))))
  (fact 10))

would be left unchanged with the outer unroll limit set to zero, but would be converted into

(letrec ((fact (lambda (x) (if (zero? x) 1 (* x (fact (- x 1)))))))
  (* 10 (fact 9)))

with the outer unroll limit set to one.

Interesting effects can be had by varying several of these parameters at once. For example, setting the effort and outer unroll limits to large values and the score limit to 1 has the effect of inlining even complex recursive procedures whose values turn out to be constant at compile time without risking any code expansion. For example,

(letrec ((fact (lambda (x) (if (zero? x) 1 (* x (fact (- x 1)))))))
  (fact 10))

would be reduced to 3628800, but

(letrec ((fact (lambda (x) (if (zero? x) 1 (* x (fact (- x 1)))))))
  (fact z))

would be left unchanged, although the optimizer may take a while to reach this decision if the effort and outer unroll limits are very large.


procedure: (expand/optimize obj)
procedure: (expand/optimize obj env)
returns: result of expanding and optimizing form represented by obj

expand/optimize treats obj as the representation of an expression. It expands the expression in environment env and passes it through a letrec optimizer, cpletrec, and the source optimizer, cp0. It returns an object representing the expanded and optimized form. If no environment is provided, it defaults to the environment returned by interaction-environment.

expand-optimize is primarily useful for understanding what cp0 does and does not optimize. Note that many optimizations are performed later in the compiler, so expand/optimize does not give a complete picture of optimizations performed.

(parameterize ([optimize-level 2])
  (expand/optimize
    '(let ([y '(3 . 4)])
       (+ (car y) (cdr y))))) <graphic> 7

(print-gensym #f)
(parameterize ([optimize-level 2])
  (expand/optimize
    '(let ([y '(3 . 4)])
       (lambda (x)
         (* (+ (car y) (cdr y)) x))))) <graphic> (lambda (x) (#2%* 7 x))

(parameterize ([optimize-level 2])
  (expand/optimize
    '(let ([n (expt 2 10)])
       (define even?
         (lambda (x) (or (zero? x) (not (odd? x)))))
       (define odd?
         (lambda (x) (not (even? (- x 1)))))
       (define f
         (lambda (x)
           (lambda (y)
             (lambda (z)
               (if (= z 0) (omega) (+ x y z))))))
       (define omega
         (lambda ()
           ((lambda (x) (x x)) (lambda (x) (x x)))))
       (let ([g (f 1)] [m (f n)])
         (let ([h (if (> ((g 2) 3) 5)
                      (lambda (x) (+ x 1))
                      odd?)])
           (h n)))))) <graphic> 1025

Section 11.6. Profiling

With profiling enabled, the compiler instruments the code it produces to count the number of times each section of code is executed. This information can be displayed in HTML format or via the profile viewer included with the Scheme Widget Library (SWL).

Profiling involves four steps:

  1. compiling code with profile instrumentation enabled,
  2. running the code to generate profiling information,
  3. dumping the profile data in raw or HTML format, and
  4. viewing the profile data.

To compile the code with profiling enabled, set the parameter compile-profile to #t while compiling your application or loading it from source. Let's assume that the file /tmp/fatfib/fatfib.ss contains the following source code.

(define fat+
  (lambda (x y)
    (if (zero? y)
        x
        (fat+ (1+ x) (1- y)))))

(define fatfib
  (lambda (x)
    (if (< x 2)
        1
        (fat+ (fatfib (1- x)) (fatfib (1- (1- x)))))))

We can load fatfib.ss with profiling enabled as follows.

(parameterize ([compile-profile #t])
  (load "/tmp/fatfib/fatfib.ss"))

We then run the application as usual.

(fatfib 20) <graphic> 10946

After the run (or multiple runs), we dump the profile information as a set of html files using profile-dump-html.

(profile-dump-html)

This creates a file named profile.html containing a summary of the profile information gathered during the run. If we view this file in a browser, we should see something like the following.

profile.html listing

The most frequently executed code is highlighted in colors closer to red in the visible spectrum, while the least frequently executed code is highlighted in colors closer to violet. Each of the entries in the lists of files and hot spots are links into additional generated files, one per source file (provided profile-dump-html was able to locate an unmodified copy of the source file). In this case, there is only one, fatfib.ss.html. If we move to that file, we should see something like this:

fatfib.html listing

As in the summary, the code is color-coded according to frequency of execution.

Profiling information may also be viewed via the SWL profview application. To use profview, we must first dump the information to a file using fasl-write and profile-dump.

(fatfib 20)
(with-output-to-file "/tmp/fatfib/pdump"
  (lambda () (fasl-write (profile-dump)))
  'replace)

Once we have the profile data, we can start SWL to run the profview application. After starting up SWL, we load profview.ss as shown below. (SWL Version 1.0d is assumed.)

(load "/usr/lib/swl1.0d/apps/profview/profview.ss")

(The actual location of profview.ss may vary from one installation to another. If you cannot locate profview.ss on your system, it can be found in the source distribution of SWL.)

The profilew viewer can then be started via p-view.

(p-view (with-input-from-file "/tmp/fatfib/pdump" read))

The profile information should look something like the following.

profile of fatfib

If the application spans multiple files, multiple files will be displayed.

If neither method for displaying profile information is suitable, profile-dump-list may be used to generate a list of profile entries, which may then be analyzed manually or via a custom profile-viewing application.


parameter: compile-profile

When this parameter is set to a true value, the compiler instruments the code it generates with instructions that count the number of times each section of code is executed. This information may be viewed in html form via profile-dump-html or dumped in raw form via profile-dump and viewed with the profview profile viewer distributed with SWL as described above. Setting this parameter also forces source information to be retained, regardless of the setting of generate-inspector-information, since this information is required by the profile viewer.

The default value of compile-profile is #f. The code generated when compile-profile is set to #t is larger and less efficient, so this parameter should be set only when profile information is needed.


procedure: (profile-clear)
returns: unspecified

Calling this procedure causes profile information to be cleared, i.e., the counts associated with each section of code are set to zero.


procedure: (profile-dump-html)
procedure: (profile-dump-html prefix)
returns: unspecified

This procedure produces one or more HTML files, including profile.html, which contains color-coded summary information, and one file source.html for each source file source containing a color-coded copy of the source code, as described in the lead-in to this section. If prefix is specified, it must be a string and is prepended to the names of the generated HTML files. For example, if prefix is "/tmp/", the generated files are placed in the directory /tmp.


parameter: (profile-palette)

This value of this parameter must be a nonempty vector of pairs. The car of each pair is a background color and the cdr is a foreground (text) color. Each color must be a string containing an HTML cascading style sheet (css) color specifier. The first pair is used for unexecuted and unprofiled code; the second for code that is executed least frequently, and so on, with the last being used for code that is executed most frequently. Programmers may wish to supply their own palette to enhance visibility or to change the number of colors used.

(profile-palette) <graphic>
  #(("black" . "white") ("#A000C8" . "black")
    ("#8200DC" . "white") ("#1E3CFF" . "white")
    ("#00A0FF" . "black") ("#00D28C" . "black")
    ("#00DC00" . "black") ("#A0E632" . "black")
    ("#E6DC32" . "black") ("#E6AF2D" . "black")
    ("#F08228" . "black") ("#FA3C3C" . "white"))
(profile-palette ; set palette with fewer colors
  '#(("black" . "white") ("#A000C8" . "black")
     ("#1E3CFF" . "white") ("#00D28C" . "black")
     ("#A0E632" . "black") ("#E6AF2D" . "black")
     ("#FA3C3C" . "white"))


procedure: (profile-dump-list)
procedure: (profile-dump-list warn?)
returns: a list of profile entries (see below)

Each profile entry in the returned list is itself a list containing the following elements, which identify one block of code and how many times it was executed.

profile-dump-list may be unable to locate an unmodified copy of the file in the current source directories or at the absolute address, if an absolute address was used when the file was compiled or loaded. If this happens, the line number and character position of the beginning file position are #f and the pathname is the pathname originally used. A warning is also issued unless the warn? argument is provided and is false.

Otherwise, the pathname is the path to an ummodified copy of the source and the line and character positions are set to nonnegative integers.

In either case, the execution count, beginning file position, and ending file position are all nonnegative integers and the pathname is a string.

The information returned by profile-dump-list can be used to implement a custom viewer or used as input for offline analysis of profiling information.


procedure: (profile-dump)
returns: raw profile information

This procedure produces a Scheme object containing a dump of all profiling information gathered since startup or the last call to profile-clear. The format of the output is unspecified but is suitable input to the SWL profview profile viewer, which is described in the lead-in to this section.

Section 11.7. Waiter Customization


procedure: (new-cafe)
procedure: (new-cafe eval-proc)
returns: see below

Chez Scheme interacts with the user through a waiter, or read-eval-print loop. The waiter operates within a context called a café. When the system starts up, the user is placed in a café and given a waiter. new-cafe opens a new Scheme café, stacked on top of the old one. In addition to starting the waiter, new-cafe sets up the café's reset and exit handlers (see reset-handler and exit-handler). Exiting a café resumes the continuation of the call to new-cafe that created the café. Exiting from the initial café leaves Scheme altogether. A café may be exited from either by an explicit call to exit or by receipt of end-of-file ("control-D" on Unix systems) in response to the waiter's prompt. In the former case, any values passed to exit are returned from new-cafe.

If the optional eval-proc argument is specified, eval-proc is used to evaluate forms entered from the console. Otherwise, the value of the parameter current-eval is used. eval-proc must accept one argument, the expression to evaluate.

Interesting values for eval-proc include expand, which causes the macro expanded value of each expression entered to be printed and (lambda (x) x), which simply causes each expression entered to be printed. An arbitrary procedure of one argument may be used to facilitate testing of a program on a series of input values.

> (new-cafe (lambda (x) x))
>> 3
3
>> (a . (b . (c . ())))
(a b c)

(define sum
  (lambda (ls)
    (if (null? ls)
        0
        (+ (car ls) (sum (cdr ls))))))
> (new-cafe sum)
>> (1 2 3)
6

The default waiter reader (see waiter-prompt-and-read) displays the current waiter prompt (see waiter-prompt-string) to the current value of the parameter console-output-port and reads from the current value of the parameter console-input-port. The default waiter printer (see waiter-write) sends output to the current value of the parameter console-output-port. These parameters, along with current-eval, can be modified to change the behavior of the waiter.


procedure: (transcript-cafe filename)

filename must be a string. transcript-cafe opens a transcript file as with transcript-on (see page t179 of The Scheme Programming Language, Third Edition) enters a new café; exiting from this café (see exit) also ends transcription and closes the transcript file. Invoking transcript-off while in a transcript café ends transcription and closes the transcript file but does not cause an exit from the café.


parameter: waiter-prompt-string

The value of waiter-prompt-string must be a string. It is used by the default waiter prompter (see the parameter waiter-prompt-and-read) to print a prompt. Nested cafés are marked by repeating the prompt string once for each nesting level.

> (waiter-prompt-string)
">"
> (waiter-prompt-string "%")
% (waiter-prompt-string)
"%"
% (new-cafe)
%% (waiter-prompt-string)
"%"


parameter: waiter-prompt-and-read

waiter-prompt-and-read must be set to a procedure. It is used by the waiter to print a prompt and read an expression. The value of waiter-prompt-and-read is called by the waiter with a positive integer that indicates the café nesting level. It should return an expression to be evaluated by the current evaluator (see new-cafe and current-eval).


procedure: (default-prompt-and-read level)

level must be a positive integer indicating the cafeé nesting level as described above.

This procedure is the default value of the waiter-prompt-and-read parameter whenever the expression editor (Section 2.2, Chapter 13) is not enabled. It might be defined as follows.

(define default-prompt-and-read
  (lambda (n)
    (unless (and (integer? n) (>= n 0))
       (error 'default-prompt-and-read
              "~s is not a nonnegative integer"
              n))
    (let ([prompt (waiter-prompt-string)])
      (unless (string=? prompt "")
        (do ([n n (- n 1)])
            ((= n 0)
             (write-char #\space (console-output-port))
             (flush-output-port (console-output-port)))
            (display prompt (console-output-port))))
      (let ([x (read (console-input-port))])
         (when (and (eof-object? x) (not (string=? prompt "")))
            (newline (console-output-port))
            (flush-output-port (console-output-port)))
         x))))


parameter: waiter-write

The value of waiter-write must be a procedure. The waiter uses the value of waiter-write to print the results of each expression read and evaluated by the waiter. The following example installs a procedure equivalent to the default waiter-write:

(waiter-write
  (lambda (x)
    (unless (eq? x (void))
      (pretty-print x (console-output-port)))
    (flush-output-port (console-output-port))))


procedure: (abort)
returns: does not return

abort invokes the current abort handler (see abort-handler).


parameter: abort-handler

The value of this parameter must be a procedure. The current abort handler is called by abort. The default abort handler exits from Scheme.


procedure: (reset)
returns: does not return

reset invokes the current reset handler (see reset-handler).


parameter: reset-handler

The value of this parameter must be a procedure. The current reset handler is called by reset. The default reset handler resets to the current café.


procedure: (exit obj ...)
returns: does not return

exit invokes the current exit handler (see exit-handler), passing along its arguments, if any.


parameter: exit-handler

The value of this parameter must be a procedure. The current exit handler is called by exit and should accept any number of arguments. The default exit handler exits from the current café, returning its arguments as the values of the call to new-cafe that created the current café.


parameter: scheme-start

The value of scheme-start is a procedure that determines the system's action upon start-up, including start-up from a saved heap. The procedure receives zero or more arguments, which are strings representing the file names (or command-line arguments not recognized by the Scheme executable) after given on the command line. The default value first loads the files named by the arguments, then starts up the initial café:

(lambda fns
  (for-each load fns)
  (new-cafe))

scheme-start may be altered to start up an application or to perform customization prior to normal system start-up.

To have any affect, this parameter must be set within a boot file or prior to the saving of a heap that is subsequently loaded. (See Chapter 2.)


parameter: scheme-script

The value of scheme-script is a procedure that determines the system's action upon start-up, including start-up from a saved heap, when the --script option is used. The procedure receives one or more arguments. The first is a string identifying the script filename and the remainder are strings representing the remaining file names (or command-line arguments not recognized by the Scheme executable) given on the command line. The default value of this parameter is a procedure that sets the command-line and command-line-arguments parameters, then loads the script.

(lambda (fn . fns)
  (command-line (cons fn fns))
  (command-line-arguments fns)
  (load fn))

scheme-script may be altered to start up an application or to perform customization prior to normal system start-up.

To have any affect, this parameter must be set within a boot file or prior to the saving of a heap that is subsequently loaded. (See Chapter 2.)


parameter: command-line

This parameter is set by the default value of scheme-script to a list representing the command line, with the script name followed by the command-line arguments, when the --script option is used on system startup.


parameter: command-line-arguments

This parameter is set by the default value of scheme-script to a list of the command-line arguments when the --script option is used on system startup.


parameter: suppress-greeting

The value of suppress-greeting is a boolean value that determines whether Chez Scheme prints an identifying banner and copyright notice. The parameter defaults to #f but may be set to #t for use in batch processing applications where the banner would be disruptive.

To have any affect, this parameter must be set within a boot file or prior to the saving of a heap that is subsequently loaded. (See Chapter 2.)

Section 11.8. Times and Dates

This section documents procedures for handling times and dates. Most of the procedures described here are proposed in SRFI 19: Time Data Types and Procedures, by Will Fitzgerald.

Times.  Times are represented by time objects. Time objects record the nanosecond and second of a particular time or duration, along with a time type that identifies the nature of the time object. The time type is one of the following symbols:

time-utc:
The time elapsed since the "epoch:" 00:00:00 UTC, January 1, 1970, subject to adjustment, e.g., to correct for leap seconds.

time-monotonic:
The time elapsed since some arbitrary point in the past, ideally not subject to adjustment.

time-duration:
The time elapsed between two times. When used as an argument to current-time, it behaves like time-monotonic, but may also used to represent the result of subtracting two time objects.

time-process:
The amount of CPU time used by the current process.

time-thread:
The amount of CPU time used by the current thread. It is the same as time-process if not running threaded or if the system does not allow individual thread times to be determined.

A time-object second is an exact integer (possibly negative), and a nanosecond is an exact nonnegative integer less than 109. The second and nanosecond of a time object may be converted to an aggregate nanosecond value by scaling the seconds by 109 and adding the nanoseconds. Thus, if the second and nanosecond of a time object are 5 and 10, the time object represents 5000000010 nanoseconds (5.000000010 seconds). If the second and nanosecond are -5 and 10, the time object represents -4999999990 nanoseconds (-4.999999990 seconds).


procedure: (current-time)
procedure: (current-time time-type)
returns: a time object representing the current time

time-type must be one of the time-type symbols listed above and defaults to time-utc.

(current-time) <graphic> #<time-utc 1198815722.473668000>
(current-time 'time-process) <graphic> #<time-process 0.120534264>


procedure: (make-time type nsec sec)
returns: a time object

type must be one of the time-type symbols listed above. nsec represents nanoseconds and must be an exact nonnegative integer less than 109. sec represents seconds and must be an exact integer.

(make-time 'time-utc 787511000 1198783214)
(make-time 'time-duration 10 5)
(make-time 'time-duration 10 -5)


procedure: (time? obj)
returns: #t if obj is a time object, #f otherwise

(time? (current-time)) <graphic> #t
(time? (make-time 'time-utc 0 0)) <graphic> #t
(time? "1400 hours") <graphic> #f


procedure: (time-type time)
returns: the time type of time
procedure: (time-nanosecond time)
returns: the nanosecond of time
procedure: (time-second time)
returns: the second of time

time must be a time object.

(time-type (current-time)) <graphic> time-utc
(time-type (current-time 'time-process)) <graphic> time-process
(time-type (make-time 'time-duration 0 50) <graphic> time-duration
(time-second (current-time)) <graphic> 1198816497
(time-nanosecond (current-time)) <graphic> 2399000
(time-second (make-time 'time-duration 10 -5)) <graphic> -5
(time-nanosecond (make-time 'time-duration 10 -5)) <graphic> 10


procedure: (set-time-type! time type)
returns: unspecified
procedure: (set-time-nanosecond! time nsec)
returns: unspecified
procedure: (set-time-second! time sec)
returns: unspecified

time must be a time object. type must be one of the time-type symbols listed above. nsec represents nanoseconds and must be an exact nonnegative integer less than 109. sec represents seconds and must be an exact integer.

Each of these procedures modifies the time object, changing one aspect while leaving the others unaffected. For example, set-time-nanosecond! changes the nanosecond of time without changing the second or type. In particular, no conversion of values is performed when the type of a time object is changed.


procedure: (time=? time1 time2)
procedure: (time<? time1 time2)
procedure: (time<=? time1 time2)
procedure: (time>=? time1 time2)
procedure: (time>? time1 time2)
returns: #t if the relation holds, #f otherwise

time1 and time2 must be time objects and must have the same type.

(let ([t (current-time)])
  (time=? t t)) <graphic> #t
(let ([t (current-time)])
  (let loop ()
    (when (time=? (current-time) t))
      (loop))
  (time>? (current-time) t)) <graphic> #t

Dates.  Dates are represented by date objects. A date object records the nanosecond, second, minute, hour, day, month, and year of a particular date, along with an offset that identifies the time zone.

As for time objects, a nanosecond is an exact integer less than 109. A date-object second is, however, an exact nonnegative integer less than 62. (The values 61 and 62 allow for leap seconds.) A minute is an exact nonnegative integer less than 60, and an hour is an exact nonnegative integer less than 24. A day is an exact nonnegative integer in ranging from 1 representing the first day of the month to n, where n is the number of days in the date's month and year. A month is an exact nonnegative integer less than 12, where 0 represents January, 1 represents February, and so on. A year must be an exact integer. Years less than 1970 or greater than 2038 may not be supported depending on limitations of the underlying implementation. A time-zone offset represents the time-zone offset, in seconds, from UTC. It is an exact integer in the range -86400 to +86400, inclusive. For example, Eastern Standard Time (EST), which is 5 hours east, has offset 5 × 3600 = -18000. The offset for Eastern Daylight Time (EDT) is -14400. UTC is represented by offset zero.


procedure: (current-date)
procedure: (current-date offset)
returns: a date object representing the current date

offset represents the time-zone offset in seconds east of UTC, as described above. It must be an exact integer in the range -86400 to +86400, inclusive and defaults to the local time-zone offset. UTC may be obtained by passing an offset of zero.

The following examples assume the local time zone is EST.

(current-date) <graphic> #<date Thu Dec 27 23:23:20 2007>
(current-date 0) <graphic> #<date Fri Dec 28 04:23:20 2007>


procedure: (make-date nsec sec min hour day mon year offset)
returns: a date object

nsec represents nanoseconds and must be an exact integer less than 109. sec represents seconds and must be an exact nonnegative integer less than 62. min represents minutes and must be an exact nonnegative integer less than 60. hour must be an exact nonnegative integer less than 24. day must be an exact integer, 1 ≤ day ≤ 31. (The actual upper limit may be less depending on the month and year.) mon represents the month must be an exact nonnegative integer less than 12. year must be an exact integer. It should be at least 1970. offset represents the time-zone offset in seconds east of UTC, as described above. It must be an exact integer in the range -86400 to +86400, inclusive. UTC may be specified by passing an offset of zero.

(make-date 0 0 0 0 1 0 1970 0) <graphic> #<date Thu Jan  1 00:00:00 1970>
(make-date 0 30 7 9 23 8 2007 -14400) <graphic> #<date Sun Sep 23 09:07:30 2007>


procedure: (date? obj)
returns: #t if obj is a date object, #f otherwise

(date? (current-date))
(date? (make-date 0 30 7 9 23 8 2007 -14400))
(date? "Sun Sep 23 09:07:30 2007") <graphic> #f


procedure: (date-nanosecond date)
returns: the nanosecond of date
procedure: (date-second date)
returns: the second of date
procedure: (date-minute date)
returns: the minute of date
procedure: (date-hour date)
returns: the hour of date
procedure: (date-day date)
returns: the day of date
procedure: (date-month date)
returns: the month of date
procedure: (date-year date)
returns: the year of date
procedure: (date-zone-offset date)
returns: the time-zone offset of date

date must be a time object.

(define d (make-date 0 30 7 9 23 8 2007 -14400))
(date-nanosecond d) <graphic> 0
(date-second d) <graphic> 30
(date-minute d) <graphic> 7
(date-hour d) <graphic> 9
(date-day d) <graphic> 23
(date-month d) <graphic> 8
(date-year d) <graphic> 2007
(date-zone-offset d) <graphic> -14400


procedure: (date-week-day date)
returns: the week-day of date
procedure: (date-year-day date)
returns: the year-day of date

These procedures allow the day-of-week or day-of-year to be determined for the date represented by date. A week-day is an exact nonnegative integer less than 7, where 0 represents Sunday, 1 represents Monday, and so on. A year-day is an exact nonnegative integer less than 367, where 0 represents the first day of the year (January 1), 1 the second day, 2 the third, and so on.

(define d1 (make-date 0 0 0 0 1 0 1970 -18000))
d1 <graphic> #<date Thu Jan  1 00:00:00 1970>
(date-week-day d1) <graphic> 4
(date-year-day d1) <graphic> 0

(define d2 (make-date 0 30 7 9 23 8 2007 -14400))
d2 <graphic> #<date Sun Sep 23 09:07:30 2007>
(date-week-day d2) :=> 0
(date-year-day d2) <graphic> 265


procedure: (date-and-time)
procedure: (date-and-time date)
returns: a string giving the current date and time

The string is always in the format illustrated by the examples below and always has length 24.

(date-and-time) <graphic> "Fri Jul 13 13:13:13 2001"
(define d (make-date 0 0 0 0 1 0 2007 0))
(date-and-time d) <graphic> "Mon Jan 01 00:00:00 2007"

Section 11.9. Timing and Statistics

This section documents procedures for timing computations. The current-time procedure described in Section 11.8 may also be used to time computations.


syntax: (time exp)
returns: value of exp

time evaluates exp and, as a side-effect, prints (to the console-output port) the amount of cpu time, the amount of real time, the number of bytes allocated, and the amount of collection overhead associated with evaluating exp.

> (time (collect))
(time (collect))
    1 collection
    1 ms elapsed cpu time, including 1 ms collecting
    1 ms elapsed real time, including 1 ms collecting
    160 bytes allocated, including 8184 bytes reclaimed


procedure: (display-statistics)
procedure: (display-statistics output-port)
returns: unspecified

This procedure displays a running total of the amount of cpu time, real time, bytes allocated, and collection overhead. If output-port is not supplied, it defaults to the current output port.


procedure: (cpu-time)
returns: the amount of cpu time consumed since system start-up

The amount is in milliseconds. The amount includes "system" as well as "user" time, i.e., time spent in the kernel on behalf of the process as well as time spent in the process itself.


procedure: (real-time)
returns: the amount of real time that has elapsed since system start-up

The amount is in milliseconds.


procedure: (bytes-allocated)
returns: the number of bytes currently allocated


procedure: (statistics)
returns: a sstats structure containing current statistics

statistics packages together various timing and allocation statistics into a single sstats structure. A sstats structure has the following fields:

cpu,
the cpu time consumed,
real,
the elapsed real time,
bytes,
the number of bytes allocated.
gc-count,
the number of collections.
gc-cpu,
the cpu time consumed during collections,
gc-real,
the elapsed real time during collections, and
gc-bytes,
the number of bytes reclaimed by the collector.

All values are computed since system start-up. All times are calculated in milliseconds.

The sstats structure and the corresponding allocation procedure, predicate, accessors, and setters described below are defined as vector-based structures as if via define-structure (Section 15.4) as follows.

(define-structure
  (sstats cpu real bytes
    gc-count gc-cpu gc-real gc-bytes))


procedure: (make-sstats cpu real bytes gc-count gc-cpu gc-real gc-bytes)
returns: a sstats structure


procedure: (sstats? obj)
returns: #t if obj is a sstats structure, otherwise #f


procedure: (sstats-cpu s)
procedure: (sstats-real s)
procedure: (sstats-bytes s)
procedure: (sstats-gc-count s)
procedure: (sstats-gc-cpu s)
procedure: (sstats-gc-real s)
procedure: (sstats-gc-bytes s)
returns: the value of the corresponding field of s

s must be a sstats structure.


procedure: (set-sstats-cpu! s obj)
procedure: (set-sstats-real! s obj)
procedure: (set-sstats-bytes! s obj)
procedure: (set-sstats-gc-count! s obj)
procedure: (set-sstats-gc-cpu! s obj)
procedure: (set-sstats-gc-real! s obj)
procedure: (set-sstats-gc-bytes! s obj)
returns: unspecified

s must be a sstats structure. Each procedure sets the value of the corresponding field to obj.


procedure: (sstats-difference s1 s2)
returns: a sstats structure representing the difference between s1 and s2

s1 and s2 must be sstats structures. sstats-difference subtracts each field of s2 from the corresponding field of s1 to produce the result sstats structure. It coerces negative results to zero. sstats-difference is commonly used to measure the time elapsed between two points in the execution of a program. In doing such comparisons, it is often useful to adjust for overhead in the statistics gathering functions by calling statistics twice before timing a computation and once after; the difference in the results of the first two calls is then subtracted from the difference in the results of the last two calls. After adjusting for overhead, small negative results could occur for very fast running computations without the coercion of negative results to zero by sstats-difference.


procedure: (sstats-print s)
procedure: (sstats-print s output-port)
returns: unspecified

s must be a sstats structure. If output-port is not supplied, it defaults to the current output port. sstats-print displays the fields of s in a manner similar to display-statistics and time.

Section 11.10. Parameters

This section describes mechanisms for creating and manipulating parameters. New parameters may be created conveniently with make-parameter. Nothing distinguishes parameters from other procedures, however, except for their behavior. If more complicated actions must be taken when a parameter is invoked than can be accommodated easily through the make-parameter mechanism, the parameter may be defined directly with case-lambda.


procedure: (make-parameter object)
procedure: (make-parameter object procedure)
returns: a parameter (procedure)

make-parameter accepts one or two arguments. The first argument is the initial value of the internal variable, and the second, if present, is a filter applied to the initial value and all subsequent values. The filter should accept one argument. If the value is not appropriate, the filter should signal an error or convert the value into a more appropriate form.

For example, the default value of print-length is defined as follows:

(define print-length
  (make-parameter
    #f
    (lambda (x)
      (unless (or (not x) (and (fixnum? x) (fx>= x 0)))
        (error 'print-length "~s is not a positive fixnum or #f" x))
      x)))

(print-length)  <graphic> #f
(print-length 3)
(print-length)  <graphic> 3
(format "~s" '(1 2 3 4 5 6))  <graphic> "(1 2 3 ...)"
(print-length #f)
(format "~s" '(1 2 3 4 5 6))  <graphic> "(1 2 3 4 5 6)"

The definition of make-parameter is straightforward using case-lambda:

(define make-parameter
  (case-lambda
    [(init guard)
     (let ([v (guard init)])
       (case-lambda
         [() v]
         [(u) (set! v (guard u))]))]
    [(init)
     (make-parameter init (lambda (x) x))]))


syntax: (parameterize ((param val) ...) exp1 exp2 ...)
returns: the value of the last expression

Using the syntactic form parameterize, the values of parameters can be changed in a manner analogous to fluid-let for ordinary variables. Each param is set to the value of the corresponding val while each expression in the body is evaluated. When control leaves the body by normal return or by the invocation of a continuation created outside of the body, the parameters are restored to their original values. If control returns to the body via a continuation created during the execution of the body, the parameters are again set to their temporary values.

(define test
  (make-parameter 0))
(test)  <graphic> 0
(test 1)
(test)  <graphic> 1
(parameterize ([test 2])
  (test))  <graphic> 2
(test)  <graphic> 1
(parameterize ([test 2])
  (test 3)
  (test))  <graphic> 3
(test)  <graphic> 1
(define k (lambda (x) x))
(begin (set! k (call/cc k))
       'k)  <graphic> k
(parameterize ([test 2])
  (test (call/cc k))
  (test))  <graphic> k
(test)  <graphic> 1
(k 3)  <graphic> 3
(test)  <graphic> 1

The definition of parameterize is similar to the definition of fluid-let (page 84):

(define-syntax parameterize
  (lambda (x)
    (syntax-case x ()
      [(_ () e1 e2 ...) (syntax (begin e1 e2 ...))]
      [(_ ([x v] ...) e1 e2 ...)
       (with-syntax ([(p ...) (generate-temporaries (syntax (x ...)))]
                     [(y ...) (generate-temporaries (syntax (x ...)))])
         (syntax
           (let ([p x] ... [y v] ...)
             (let ([swap (lambda ()
                           (let ([t (p)]) (p y) (set! y t)) ...)])
               (dynamic-wind swap (lambda () e1 e2 ...) swap)))))])))

Section 11.11. Environmental Queries and Settings


procedure: (getenv key)
returns: environment value of key or #f

key must be a string. getenv returns the operating system shell's environment value associated with key, or #f if no environment value is associated with key.

(getenv "HOME") <graphic> "/u/freddy"


procedure: (putenv key value)
returns: unspecified

key and value must be strings.

putenv stores the key, value pair in the environment of the process, where it is available to the current process (e.g., via getenv) and any spawned processes. The key and value are copied into storage allocated outside of the Scheme heap; this space is never reclaimed.

(putenv "SCHEME" "rocks!")
(getenv "SCHEME") <graphic> "rocks!"


procedure: (get-registry key)
returns: registry value of key or #f
procedure: (put-registry! key val)
procedure: (remove-registry! key)
returns: unspecified

key and val must be strings.

get-registry returns a string containing the registry value of key if the value exists. If no registry value for key exists, get-registry returns #f.

put-registry! sets the registry value of key to val. It signals an error if the value cannot be set, which may happen if the user has insufficient access.

remove-registry! removes the registry key or value named by key. It signals an error if the value cannot be removed. Reasons for failure include the key not being present, the user having insufficient access, or key being a key with subkeys.

These routines are defined for Windows only.

(get-registry "hkey_local_machine\\Software\\North\\South") <graphic> #f
(put-registry! "hkey_local_machine\\Software\\North\\South" "east")
(get-registry "hkey_local_machine\\Software\\North\\South") <graphic> "east"
(remove-registry! "hkey_local_machine\\Software\\North")
(get-registry "hkey_local_machine\\Software\\North\\South") <graphic> #f

Section 11.12. Subset Modes


parameter: subset-mode

The value of this parameter must be #f (the default) or the symbol system. Setting subset-mode to system allows the manipulation of various undocumented system variables, data structures, and settings. It is typically used only for system debugging.

R. Kent Dybvig / Chez Scheme Version 7 User's Guide
Copyright © 2005 R. Kent Dybvig
Revised July 2007 for Chez Scheme Version 7.4
Cadence Research Systems / www.scheme.com
Cover illustration © 1998 Jean-Pierre Hébert
ISBN: 0-9667139-1-5
to order this book / about this book