1. Parameters
    1. make-parameter
  2. Built-in parameters
    1. case-sensitive
    2. dynamic-load-libraries
    3. command-line-arguments
    4. current-read-table
    5. exit-handler
    6. eval-handler
    7. force-finalizers
    8. implicit-exit-handler
    9. keyword-style
    10. parenthesis-synonyms
    11. symbol-escape
    12. load-verbose
    13. program-name
    14. repl-prompt
    15. reset-handler
    16. recursive-hash-max-depth
    17. recursive-hash-max-length

Parameters

Parameters are Chicken's form of dynamic variables, except that they are procedures rather than actual variables. A parameter is a procedure of zero or one arguments. To retrieve the value of a parameter call the parameter-procedure with zero arguments. To change the setting of the parameter, call the parameter-procedure with the new value as argument:

(define foo (make-parameter 123))
(foo)                             ==> 123
(foo 99)
(foo)                             ==> 99

Parameters are fully thread-local, each thread of execution owns a local copy of a parameters' value.

CHICKEN implements SRFI-39.

make-parameter

[procedure] (make-parameter VALUE [GUARD])

Returns a procedure that accepts zero or one argument. Invoking the procedure with zero arguments returns VALUE. Invoking the procedure with one argument changes its value to the value of that argument and returns the new value (subsequent invocations with zero parameters return the new value). GUARD should be a procedure of a single argument. Any new values of the parameter (even the initial value) are passed to this procedure. The guard procedure should check the value and/or convert it to an appropriate form.

Built-in parameters

Certain behavior of the interpreter and compiled programs can be customized via the following built-in parameters:

case-sensitive

[parameter] (case-sensitive)

If true, then read reads symbols and identifiers in case-sensitive mode and uppercase characters in symbols are printed escaped. Defaults to #t.

dynamic-load-libraries

[parameter] (dynamic-load-libraries)

A list of strings containing shared libraries that should be checked for explicitly loaded library units (this facility is not available on all platforms). See load-library.

command-line-arguments

[parameter] (command-line-arguments)

Contains the list of arguments passed to this program, with the name of the program and any runtime options (all options starting with -:) removed.

current-read-table

[parameter] (current-read-table)

A read-table object that holds read-procedures for special non-standard read-syntax (see set-read-syntax! for more information).

exit-handler

[parameter] (exit-handler)

A procedure of a single optional argument. When exit is called, then this procedure will be invoked with the exit-code as argument. The default behavior is to terminate the program.

eval-handler

[parameter] (eval-handler)

A procedure of one or two arguments. When eval is invoked, it calls the value of this parameter with the same arguments. The default behavior is to evaluate the argument expression and to ignore the second parameter.

force-finalizers

[parameter] (force-finalizers)

If true, force and execute all pending finalizers before exiting the program (either explicitly by exit or implicitly when the last toplevel expression has been executed). Default is #t.

implicit-exit-handler

[parameter] (implicit-exit-handler)

A procedure of no arguments. When the last toplevel expression of the program has executed, then the value of this parameter is called. The default behaviour is to invoke all pending finalizers.

keyword-style

[parameter] (keyword-style)

Enables alternative keyword syntax, where STYLE may be either #:prefix (as in Common Lisp), which recognizes symbols beginning with a colon as keywords, or #:suffix (as in DSSSL), which recognizes symbols ending with a colon as keywords. Any other value disables the alternative syntaxes. In the interpreter the default is #:suffix.

parenthesis-synonyms

[parameter] (parenthesis-synonyms)

If true, then the list delimiter synonyms #\[ #\] and #\{ #\} are enabled. Defaults to #t.

symbol-escape

[parameter] (symbol-escape)

If true, then the symbol escape #\| #\| is enabled. Defaults to #t.

load-verbose

[parameter] (load-verbose)

A boolean indicating whether loading of source files, compiled code (if available) and compiled libraries should display a message.

program-name

[parameter] (program-name)

The name of the currently executing program. This is equivalent to (car (argv)) for compiled programs or the filename following the -script option in interpreted scripts.

repl-prompt

[parameter] (repl-prompt)

A procedure that should evaluate to a string that will be printed before reading interactive input from the user in a read-eval-print loop. Defaults to (lambda () "#;N> ").

reset-handler

[parameter] (reset-handler)

A procedure of zero arguments that is called via reset. The default behavior in compiled code is to invoke the value of (exit-handler). The default behavior in the interpreter is to abort the current computation and to restart the read-eval-print loop.

recursive-hash-max-depth

[parameter] (recursive-hash-max-depth)

The maximum structure depth to follow when computing a hash value. The default is 4.

recursive-hash-max-length

[parameter] (recursive-hash-max-depth)

The maximum vector length to follow when computing a hash value. The default is 4.


Previous: Declarations Next: Exceptions