Outdated CHICKEN release

This is a manual page for an old and unsupported version of CHICKEN. If you are still using it, please consider migrating to the latest version. You can find the manual for the latest release here.

  1. Outdated CHICKEN release
  2. Unit library
    1. Arithmetic
      1. add1/sub1
      2. Binary integer operations
      3. bit-set?
      4. Arithmetic fixnum operations
      5. Fixnum comparison and predicates
      6. fixnum?
      7. Fixnum limits
      8. Arithmetic floating-point operations
      9. flonum?
      10. Flonum limits
      11. finite?
      12. signum
    2. File Input/Output
      1. current-output-port
      2. current-error-port
      3. flush-output
      4. port-closed?
      5. port-name
      6. port-position
      7. set-port-name!
    3. Files
      1. delete-file
      2. directory-exists?
      3. file-exists?
      4. rename-file
    4. String ports
      1. get-output-string
      2. open-input-string
      3. open-output-string
    5. Feature identifiers
      1. features
      2. feature?
      3. register-feature!
      4. unregister-feature!
    6. Keywords
      1. get-keyword
      2. keyword?
      3. keyword->string
      4. string->keyword
    7. Environment information and system interface
      1. argv
      2. exit
      3. build-platform
      4. chicken-version
      5. errno
      6. get-environment-variable
      7. machine-byte-order
      8. machine-type
      9. on-exit
      10. software-type
      11. software-version
      12. system
    8. Execution time
      1. cpu-time
      2. current-milliseconds
      3. current-seconds
      4. current-gc-milliseconds
    9. Interrupts and error-handling
      1. enable-warnings
      2. error
      3. get-call-chain
      4. print-call-chain
      5. print-error-message
      6. procedure-information
      7. quit
      8. reset
      9. warning
    10. Garbage collection
      1. gc
      2. memory-statistics
      3. set-finalizer!
      4. set-gc-report!
    11. Other predicates and comparison operations
      1. promise?
      2. equal=?
    12. String utilities
      1. reverse-list->string
    13. Symbols
      1. Symbol utilities
        1. symbol-append
      2. Uninterned symbols ("gensyms")
        1. gensym
        2. string->uninterned-symbol
      3. Property lists
        1. get
        2. put!
        3. remprop!
        4. symbol-plist
        5. get-properties
    14. Standard Input/Output
      1. port?
      2. print
      3. print*
    15. User-defined named characters
      1. char-name
    16. Blobs
      1. make-blob
      2. blob?
      3. blob-size
      4. blob->string
      5. string->blob
      6. blob=?
    17. Lists
      1. foldl
      2. foldr
    18. Vectors
      1. vector-copy!
      2. vector-resize
      3. subvector
    19. The unspecified value
      1. void
    20. Continuations
      1. call/cc
      2. continuation-capture
      3. continuation?
      4. continuation-graft
      5. continuation-return
    21. Setters
      1. setter
      2. getter-with-setter
    22. Reader extensions
      1. define-reader-ctor
      2. set-read-syntax!
      3. set-sharp-read-syntax!
      4. set-parameterized-read-syntax!
      5. copy-read-table

Unit library

This unit contains basic Scheme definitions. This unit is used by default, unless the program is compiled with the -explicit-use option.



[procedure] (add1 N)
[procedure] (sub1 N)

Adds/subtracts 1 from N.

Binary integer operations

[procedure] (bitwise-and N1 ...)
[procedure] (bitwise-ior N1 ...)
[procedure] (bitwise-xor N1 ...)
[procedure] (bitwise-not N)
[procedure] (arithmetic-shift N1 N2)

Binary integer operations. arithmetic-shift shifts the argument N1 by N2 bits to the left. If N2 is negative, then N1 is shifted to the right. These operations only accept exact integers or inexact integers in word range (32 bit signed on 32-bit platforms, or 64 bit signed on 64-bit platforms).


[procedure] (bit-set? N INDEX)

Returns #t if the bit at the position INDEX in the integer N is set, or #f otherwise. The rightmost/least-significant bit is bit 0.

Arithmetic fixnum operations

[procedure] (fx+ N1 N2)
[procedure] (fx- N1 N2)
[procedure] (fx* N1 N2)
[procedure] (fx/ N1 N2)
[procedure] (fxmod N1 N2)
[procedure] (fxneg N)
[procedure] (fxmin N1 N2)
[procedure] (fxmax N1 N2)
[procedure] (fxand N1 N2)
[procedure] (fxior N1 N2)
[procedure] (fxxor N1 N2)
[procedure] (fxnot N)
[procedure] (fxshl N1 N2)
[procedure] (fxshr N1 N2)

fx+ and friends are arithmetic fixnum operations. These procedures do not check their arguments, so non-fixnum parameters will result in incorrect results. fxneg negates its argument.

On division by zero, fx/ and fxmod signal a condition of kind (exn arithmetic).

fxshl and fxshr perform arithmetic shift left and right, respectively.

Fixnum comparison and predicates

[procedure] (fxodd? N)
[procedure] (fxeven? N)
[procedure] (fx= N1 N2)
[procedure] (fx> N1 N2)
[procedure] (fx< N1 N2)
[procedure] (fx>= N1 N2)
[procedure] (fx<= N1 N2)

Comparison of fixnums and predicates on them.


[procedure] (fixnum? X)

Returns #t if X is a fixnum, or #f otherwise.

Fixnum limits

[constant] most-positive-fixnum
[constant] most-negative-fixnum
[constant] fixnum-bits
[constant] fixnum-precision

Platform-specific fixnum limits.

Arithmetic floating-point operations

[procedure] (fp+ X Y)
[procedure] (fp- X Y)
[procedure] (fp* X Y)
[procedure] (fp/ X Y)
[procedure] (fpneg X)
[procedure] (fpmin X Y)
[procedure] (fpmax X Y)
[procedure] (fp= X Y)
[procedure] (fp> X Y)
[procedure] (fp< X Y)
[procedure] (fp>= X Y)
[procedure] (fp<= X Y)
[procedure] (fpfloor X)
[procedure] (fpceiling X)
[procedure] (fptruncate X)
[procedure] (fpround X)
[procedure] (fpsin X)
[procedure] (fpcos X)
[procedure] (fptan X)
[procedure] (fpasin X)
[procedure] (fpacos X)
[procedure] (fpatan X)
[procedure] (fpatan2 X Y)
[procedure] (fplog X)
[procedure] (fpexp X)
[procedure] (fpexpt X Y)
[procedure] (fpsqrt X)
[procedure] (fpabs X)
[procedure] (fpinteger? X)

Arithmetic floating-point operations.

In safe mode, these procedures throw a type error when given non-float arguments. In unsafe mode, these procedures do not check their arguments. A non-flonum argument in unsafe mode can crash the application.

Note: fpround uses the rounding mode that your C library implements, which is usually different from R5RS.


[procedure] (flonum? X)

Returns #t if X is a flonum, or #f otherwise.

Flonum limits

[constant] maximum-flonum
[constant] minimum-flonum
[constant] flonum-radix
[constant] flonum-epsilon
[constant] flonum-precision
[constant] flonum-decimal-precision
[constant] flonum-maximum-exponent
[constant] flonum-minimum-exponent
[constant] flonum-maximum-decimal-exponent
[constant] flonum-minimum-decimal-exponent

Platform-specific flonum limits.

[procedure] (flonum-print-precision [PRECISION])

Gets and sets the number of significant digits printed for a floating-point number. PRECISION must be a positive fixnum. Returns the setting that was previously in effect.

The default print precision is 15 on nearly all systems, and 7 on the rare system on which the double type is only single-precision.

Note: To ensure read/write invariance for all floating-point numbers, you must increase print precision from 15 to 17 (or from 7 to 9). For example:

> (define a (expt 2 -53))
> (define b (+ a (* 2 (expt 10 -32))))
> (eqv? a b)
> (flonum-print-precision 15)
> (cons a b)
(1.11022302462516e-16 .
 1.11022302462516e-16)            ;; same printed representation
> (flonum-print-precision 17)
> (cons a b)
(1.1102230246251565e-16 .
 1.1102230246251568e-16)          ;; differs in last place

On the downside, this will result in unnecessarily precise representations of many numbers:

> (flonum-print-precision 17)
> 0.1

The maximum number of decimal digits required to uniquely represent all floating-point numbers of a certain precision is given by the formula ceil(1+N*log10(2)), where N is the number of bits of precision; for double-precision, N=53.


[procedure] (finite? N)

Returns #f if N is negative or positive infinity, and #t otherwise.


[procedure] (signum N)

Returns 1 if N is positive, -1 if N is negative or 0 if N is zero. signum is exactness preserving.

File Input/Output


[procedure] (current-output-port [PORT])

Returns default output port. If PORT is given, then that port is selected as the new current output port.

Note that the default output port is not buffered. Use set-buffering-mode! if you need a different behavior.


[procedure] (current-error-port [PORT])

Returns default error output port. If PORT is given, then that port is selected as the new current error output port.

Note that the default error output port is not buffered. Use set-buffering-mode! if you need a different behavior.


[procedure] (flush-output [PORT])

Write buffered output to the given output-port. PORT defaults to the value of (current-output-port).


[procedure] (port-closed? PORT)

Is the given PORT closed?


[procedure] (port-name [PORT])

Fetch filename from PORT. This returns the filename that was used to open this file. Returns a special tag string, enclosed into parentheses for non-file ports. PORT defaults to the value of (current-input-port).


[procedure] (port-position [PORT])

Returns the current position of PORT as two values: row and column number. If the port does not support such an operation an error is signaled. This procedure is currently only available for input ports. PORT defaults to the value of (current-input-port).


[procedure] (set-port-name! PORT STRING)

Sets the name of PORT to STRING.



[procedure] (delete-file STRING)

Deletes the file with the pathname STRING. If the file does not exist, an error is signaled.


[procedure] (directory-exists? STRING)

Returns STRING if a directory with the given pathname exists, or #f otherwise.


[procedure] (file-exists? STRING)

Returns STRING if a file or directory with the given pathname exists, or #f otherwise.


[procedure] (rename-file OLD NEW)

Renames the file or directory with the pathname OLD to NEW. If the operation does not succeed, an error is signaled.

String ports


[procedure] (get-output-string PORT)

Returns accumulated output of a port created with (open-output-string).


[procedure] (open-input-string STRING)

Returns a port for reading from STRING.


[procedure] (open-output-string)

Returns a port for accumulating output in a string.

Feature identifiers

CHICKEN maintains a global list of features naming functionality available in the current system. Additionally the cond-expand form accesses this feature list to infer what features are provided. Predefined features are chicken, and the SRFIs (Scheme Request For Implementation) provided by the base system: srfi-23, srfi-30, srfi-39. If the eval unit is used (the default), the features srfi-0, srfi-2, srfi-6, srfi-8, srfi-9 and srfi-10 are defined. When compiling code (during compile-time) the feature compiling is registered. When evaluating code in the interpreter (csi), the feature csi is registered.


[procedure] (features)

Returns a list of all registered features that will be accepted as valid feature-identifiers by cond-expand.


[procedure] (feature? ID ...)

Returns #t if all features with the given feature-identifiers ID ... are registered.


[procedure] (register-feature! FEATURE ...)

Register one or more features that will be accepted as valid feature-identifiers by cond-expand. FEATURE ... may be a keyword, string or symbol.


[procedure] (unregister-feature! FEATURE ...)

Unregisters the specified feature-identifiers. FEATURE ... may be a keyword, string or symbol.


Keywords are special symbols prefixed with #: that evaluate to themselves. Procedures can use keywords to accept optional named parameters in addition to normal required parameters. Assignment to and bindings of keyword symbols is not allowed. The parameter keyword-style and the compiler/interpreter option -keyword-style can be used to allow an additional keyword syntax, either compatible to Common LISP, or to DSSSL. As long as this parameter is set to #:suffix, CHICKEN conforms to SRFI-88.


[procedure] (get-keyword KEYWORD ARGLIST [THUNK])

Returns the argument from ARGLIST specified under the keyword KEYWORD. If the keyword is not found, then the zero-argument procedure THUNK is invoked and the result value is returned. If THUNK is not given, #f is returned.

(define (increase x . args)
  (+ x (get-keyword #:amount args (lambda () 1))) )
(increase 123)                                      ==> 124
(increase 123 #:amount 10)                          ==> 133

Note: the KEYWORD may actually be any kind of object.


[procedure] (keyword? X)

Returns #t if X is a keyword symbol, or #f otherwise.


[procedure] (keyword->string KEYWORD)

Transforms KEYWORD into a string.


[procedure] (string->keyword STRING)

Returns a keyword with the name STRING.

Environment information and system interface


[procedure] (argv)

Return a list of all supplied command-line arguments. The first item in the list is a string containing the name of the executing program. The other items are the arguments passed to the application. It depends on the host-shell whether arguments are expanded ('globbed') or not.


[procedure] (exit [CODE])

Exit the running process and return exit-code, which defaults to 0 (Invokes exit-handler).

Note that pending dynamic-wind thunks are not invoked when exiting your program in this way.


[procedure] (build-platform)

Returns a symbol specifying the toolset which has been used for building the executing system, which is one of the following:



[procedure] (chicken-version [FULL])

Returns a string containing the version number of the CHICKEN runtime system. If the optional argument FULL is given and true, then a full version string is returned.


[procedure] (errno)

Returns the error code of the last system call.


[procedure] (get-environment-variable STRING)

Returns the value of the environment variable STRING or #f if that variable is not defined. See also SRFI-98.


[procedure] (machine-byte-order)

Returns the symbol little-endian or big-endian, depending on the machine's byte-order.


[procedure] (machine-type)

Returns a symbol specifying the processor on which this process is currently running, which is one of the following:



[procedure] (on-exit THUNK)

Schedules the zero-argument procedures THUNK to be executed before the process exits, either explicitly via exit or implicitly after execution of the last top-level form. Note that finalizers for unreferenced finalized data are run before exit procedures.


[procedure] (software-type)

Returns a symbol specifying the operating system on which this process is currently running, which is one of the following:



[procedure] (software-version)

Returns a symbol specifying the operating system version on which this process is currently running, which is one of the following:



[procedure] (system STRING)

Execute shell command. The functionality offered by this procedure depends on the capabilities of the host shell. If the forking of a subprocess failed, an exception is raised. Otherwise the return status of the subprocess is returned unaltered.

On a UNIX system, that value is the raw return value of waitpid(2), which contains signal, core dump and exit status. It is 0 on success. To pull out the signal number or exit status portably requires POSIX calls, but in a pinch you can use something like this:

;; Returns two values: #t if the process exited normally or #f otherwise;
;; and either the exit status, or the signal number if terminated via signal.
(define (process-status rc)
  (define (wait-signaled? x) (not (= 0 (bitwise-and x 127))))
  (define (wait-signal x) (bitwise-and x 127))
  (define (wait-exit-status x) (arithmetic-shift x -8))
  (if (wait-signaled? rc)
      (values #f (wait-signal rc))
      (values #t (wait-exit-status rc))))

#;> (process-status (system "exit 42"))

Execution time


[procedure] (cpu-time)

Returns the used CPU time of the current process in milliseconds as two values: the time spent in user code, and the time spent in system code. On platforms where user and system time can not be differentiated, system time will be always be 0.


[procedure] (current-milliseconds)

Returns the number of milliseconds since process- or machine startup.


[procedure] (current-seconds)

Returns the number of seconds since midnight, Jan. 1, 1970.


[procedure] (current-gc-milliseconds)

Returns the number of milliseconds spent in major garbage collections since the last call of current-gc-milliseconds and returns an exact integer.

Interrupts and error-handling


[procedure] (enable-warnings [BOOL])

Enables or disables warnings, depending on wether BOOL is true or false. If called with no arguments, this procedure returns #t if warnings are currently enabled, or #f otherwise. Note that this is not a parameter. The current state (whether warnings are enabled or disabled) is global and not thread-local.


[procedure] (error [LOCATION] [STRING] EXP ...)

Prints error message, writes all extra arguments to the value of (current-error-port) and invokes the current exception-handler. This conforms to SRFI-23. If LOCATION is given and a symbol, it specifies the location (the name of the procedure) where the error occurred.


[procedure] (get-call-chain [START [THREAD]])

Returns a list with the call history. Backtrace information is only generated in code compiled without -no-trace and evaluated code. If the optional argument START is given, the backtrace starts at this offset, i.e. when START is 1, the next to last trace-entry is printed, and so on. If the optional argument THREAD is given, then the call-chain will only be constructed for calls performed by this thread.

[procedure] (print-call-chain [PORT [START [THREAD [HEADER]]]])

Prints a backtrace of the procedure call history to PORT, which defaults to (current-output-port). The output is prefixed by the HEADER, which defaults to "\n\tCall history:\n".

[procedure] (print-error-message EXN [PORT [HEADER]])

Prints an appropriate error message to PORT (which defaults to the value of (current-output-port) for the object EXN. EXN may be a condition, a string or any other object. The output is prefixed by the HEADER, which defaults to "Error:".


[procedure] (procedure-information PROC)

Returns an s-expression with debug information for the procedure PROC, or #f, if PROC has no associated debug information.


[procedure] (quit [RESULT])

In the interpreter quit exits the currently active read-eval-print loop. In compiled code, it is equivalent to calling exit. See also: repl.


[procedure] (reset)

Reset program (Invokes reset-handler).


[procedure] (warning STRING EXP ...)

Displays a warning message (if warnings are enabled with enable-warnings) and continues execution.

Garbage collection


[procedure] (gc [FLAG])

Invokes a garbage-collection and returns the number of free bytes in the heap. The flag specifies whether a minor (#f) or major (#t) GC is to be triggered. If no argument is given, #t is assumed. An explicit #t argument will cause all pending finalizers to be executed.


[procedure] (memory-statistics)

Performs a major garbage collection and returns a three element vector containing the total heap size in bytes, the number of bytes currently used and the size of the nursery (the first heap generation). Note that the actual heap is actually twice the size given in the heap size, because CHICKEN uses a copying semi-space collector.


[procedure] (set-finalizer! X PROC)

Registers a procedure of one argument PROC, that will be called as soon as the non-immediate data object X is about to be garbage-collected (with that object as its argument). Note that the finalizer will not be called while interrupts are disabled. This procedure returns X.

Finalizers are invoked asynchronously, in the thread that happens to be currently running. Finalizers for data that has become garbage are called on normal program exit. Finalizers are not run on abnormal program exit. A normal program exit does not run finalizers that are still reachable from global data.

Multiple finalizers can be registered for the same object. The order in which the finalizers run is undefined. Execution of finalizers may be nested.


[procedure] (set-gc-report! FLAG)

Print statistics after every GC, depending on FLAG. A value of #t shows statistics after every major GC. A true value different from #t shows statistics after every minor GC. #f switches statistics off.

Other predicates and comparison operations


[procedure] (promise? X)

Returns #t if X is a promise returned by delay, or #f otherwise.


[procedure] (equal=? X y)

Similar to the standard procedure equal?, but compares numbers using the = operator, so equal=? allows structural comparison in combination with comparison of numerical data by value.

String utilities


[procedure] (reverse-list->string LIST)

Returns a string with the characters in LIST in reverse order. This is equivalent to (list->string (reverse LIST)), but much more efficient.


Symbol utilities

[procedure] (symbol-append SYMBOL1 ...)

Creates a new symbol from the concatenated names of the argument symbols (SYMBOL1 ...).

Uninterned symbols ("gensyms")

Symbols may be "interned" or "uninterned". Interned symbols are registered in a global table, and when read back from a port are identical to a symbol written before:

(define sym 'foo)

(eq? sym (with-input-from-string
              (lambda () (write sym)))

  => #t

Uninterned symbols on the other hand are not globally registered and so multiple symbols with the same name may coexist:

(define sym (gensym 'foo))   ; sym is a uninterned symbol like "foo42"

(eq? sym (with-input-from-string    ; the symbol read will be an interned symbol
              (lambda () (write sym)))

  => #f

(eq? (string->uninterned-symbol "foo") (string->uninterned-symbol "foo"))

  => #f

Use uninterned symbols if you need to generate unique values that can be compared quickly, for example as keys into a hash-table or association list. Note that uninterned symbols lose their uniqueness property when written to a file and read back in, as in the example above.

[procedure] (gensym [STRING-OR-SYMBOL])

Returns a newly created uninterned symbol. If an argument is provided, the new symbol is prefixed with that argument.

[procedure] (string->uninterned-symbol STRING)

Returns a newly created, unique symbol with the name STRING.

Property lists

As in other Lisp dialects, CHICKEN supports "property lists" associated with symbols. Properties are accessible via a key that can be any kind of value but which will be compared using eq?.

[procedure] (get SYMBOL PROPERTY [DEFAULT])

Returns the value stored under the key PROPERTY in the property list of SYMBOL. If no such property is stored, returns DEFAULT. The DEFAULT is optional and defaults to #f.

[procedure] (put! SYMBOL PROPERTY VALUE)

setter: (set! (get SYMBOL PROPERTY) VALUE)

Stores VALUE under the key PROPERTY in the property list of SYMBOL replacing any previously stored value.

[procedure] (remprop! SYMBOL PROPERTY)

Deletes the first property matching the key PROPERTY in the property list of SYMBOL. Returns #t when a deletion performed, and #f otherwise.

[procedure] (symbol-plist SYMBOL)

setter: (set! (symbol-plist SYMBOL) LST)

Returns the property list of SYMBOL or sets it.

[procedure] (get-properties SYMBOL PROPERTIES)

Searches the property list of SYMBOL for the first property with a key in the list PROPERTIES. Returns 3 values: the matching property key, value, and the tail of property list after the matching property. When no match found all values are #f.

PROPERTIES may also be an atom, in which case it is treated as a list of one element.

Standard Input/Output


[procedure] (port? X)

Returns #t if X is a port object or #f otherwise.


[procedure] (print [EXP1 ...])

Outputs the optional arguments EXP1 ... using display and writes a newline character to the port that is the value of (current-output-port). Returns (void).


[procedure] (print* [EXP1 ...])

Similar to print, but does not output a terminating newline character and performs a flush-output after writing its arguments.

User-defined named characters


[procedure] (char-name SYMBOL-OR-CHAR [CHAR])

This procedure can be used to inquire about character names or to define new ones. With a single argument the behavior is as follows: If SYMBOL-OR-CHAR is a symbol, then char-name returns the character with this name, or #f if no character is defined under this name. If SYMBOL-OR-CHAR is a character, then the name of the character is returned as a symbol, or #f if the character has no associated name.

If the optional argument CHAR is provided, then SYMBOL-OR-CHAR should be a symbol that will be the new name of the given character. If multiple names designate the same character, then the write will use the character name that was defined last.

(char-name 'space)                  ==> #\space
(char-name #\space)                 ==> space
(char-name 'bell)                   ==> #f
(char-name (integer->char 7))       ==> #f
(char-name 'bell (integer->char 7))
(char-name 'bell)                   ==> #\bell
(char->integer (char-name 'bell))   ==> 7


"blobs" are collections of unstructured bytes. You can't do much with them, but allow conversion to and from SRFI-4 number vectors.


[procedure] (make-blob SIZE)

Returns a blob object of SIZE bytes, aligned on an 8-byte boundary, uninitialized.


[procedure] (blob? X)

Returns #t if X is a blob object, or #f otherwise.


[procedure] (blob-size BLOB)

Returns the number of bytes in BLOB.


[procedure] (blob->string BLOB)

Returns a string with the contents of BLOB.


[procedure] (string->blob STRING)

Returns a blob with the contents of STRING.


[procedure] (blob=? BLOB1 BLOB2)

Returns #t if the two argument blobs are of the same size and have the same content.



[procedure] (foldl PROCEDURE INIT LIST)

Applies PROCEDURE to the elements from LIST, beginning from the left:

(foldl + 0 '(1 2 3))    ==>    (+ (+ (+ 0 1) 2) 3)

Note that the order of arguments taken by PROCEDURE is different from the SRFI-1 fold procedure, but matches the more natural order used in Haskell and Objective Caml.


[procedure] (foldr PROCEDURE INIT LIST)

Applies PROCEDURE to the elements from LIST, beginning from the right:

(foldr + 0 '(1 2 3))    ==>    (+ 1 (+ 2 (+ 3 0)))



[procedure] (vector-copy! VECTOR1 VECTOR2 [COUNT])

Copies contents of VECTOR1 into VECTOR2. If the argument COUNT is given, it specifies the maximal number of elements to be copied. If not given, the minimum of the lengths of the argument vectors is copied.

Exceptions: (exn bounds)


[procedure] (vector-resize VECTOR N [INIT])

Creates and returns a new vector with the contents of VECTOR and length N. If N is greater than the original length of VECTOR, then all additional items are initialized to INIT. If INIT is not specified, the contents are initialized to some unspecified value.


[procedure] (subvector VECTOR FROM [TO])

Returns a new vector with elements taken from VECTOR in the given range. TO defaults to (vector-length VECTOR).

subvector was introduced in CHICKEN 4.7.3.

The unspecified value


[procedure] (void ARGUMENT ...)

Ignores ARGUMENT ... and returns an unspecified value.



[procedure] (call/cc PROCEDURE)

An alias for call-with-current-continuation.


[procedure] (continuation-capture PROCEDURE)

Creates a continuation object representing the current continuation and tail-calls PROCEDURE with this continuation as the single argument.

More information about this continuation API can be found in the paper http://repository.readscheme.org/ftp/papers/sw2001/feeley.pdf A Better API for first class Continuations by Marc Feeley.


[procedure] (continuation? X)

Returns #t if X is a continuation object, or #f otherwise. Please note that this applies only to continuations created by the Continuation API, but not by call/cc, i.e.: (call-with-current-continuation continuation?) returns #f, whereas (continuation-capture continuation?) returns #t.


[procedure] (continuation-graft CONT THUNK)

Calls the procedure THUNK with no arguments and the implicit continuation CONT.


[procedure] (continuation-return CONT VALUE ...)

Returns the value(s) to the continuation CONT. continuation-return could be implemented like this:

(define (continuation-return k . vals)
    (lambda () (apply values vals)) ) )


SRFI-17 is fully implemented. For more information see: SRFI-17.


[procedure] (setter PROCEDURE)

Returns the setter-procedure of PROCEDURE, or signals an error if PROCEDURE has no associated setter-procedure.

Note that (set! (setter PROC) ...) for a procedure that has no associated setter procedure yet is a very slow operation (the old procedure is replaced by a modified copy, which involves a garbage collection).


[procedure] (getter-with-setter GETTER SETTER)

Returns a copy of the procedure GETTER with the associated setter procedure SETTER. Contrary to the SRFI specification, the setter of the returned procedure may be changed.

Reader extensions


[procedure] (define-reader-ctor SYMBOL PROC)

Define new read-time constructor for #, read syntax. For further information, see the documentation for SRFI-10.


[procedure] (set-read-syntax! CHAR-OR-SYMBOL PROC)

When the reader encounters the non-whitespace character CHAR while reading an expression from a given port, then the procedure PROC will be called with that port as its argument. The procedure should return a value that will be returned to the reader:

 ; A simple RGB color syntax:

 (set-read-syntax! #\%
   (lambda (port)
     (apply vector
       (map (cut string->number <> 16)
	    (string-chop (read-string 6 port) 2) ) ) ) )

 (with-input-from-string "(1 2 %f0f0f0 3)" read)
 ; ==> (1 2 #(240 240 240) 3)

If CHAR-OR-SYMBOL is a symbol, then a so-called read-mark handler is defined. In that case the handler procedure will be called when a character-sequence of the form #!SYMBOL is encountered.

You can undo special handling of read-syntax by passing #f as the second argument (if the syntax was previously defined via set-read-syntax!).

As a special case, your handler can return zero values, via (values). This causes the reader to completely ignore whatever input you've read, rather than returning some possibly unspecified value. This can be useful in macro context, reading comments, conditional compilation, and so forth. Available in CHICKEN 4.6.6 and later.

Note that all of CHICKEN's special non-standard read-syntax is handled directly by the reader. To disable built-in read-syntax, define a handler that triggers an error (for example).


[procedure] (set-sharp-read-syntax! CHAR-OR-SYMBOL PROC)

Similar to set-read-syntax!, but allows defining new #<CHAR> ... reader syntax. If the first argument is a symbol, then this procedure is equivalent to set-read-syntax!.

PROC may be #f to disable previously defined "sharp" read syntax.


[procedure] (set-parameterized-read-syntax! CHAR-OR-SYMBOL PROC)

Similar to set-sharp-read-syntax!, but intended for defining reader syntax of the form #<NUMBER><CHAR> .... The handler procedure PROC will be called with two arguments: the input port and the number preceding the dispatching character. If the first argument is a symbol, then this procedure is equivalent to set-read-syntax!.

PROC may be #f to disable previously defined parameterized read syntax.


[procedure] (copy-read-table READ-TABLE)

Returns a copy of the given read-table. You can access the currently active read-table with (current-read-table).

Previous: Exceptions Next: Unit eval