1. Module (chicken keyword)
    1. get-keyword
    2. keyword?
    3. keyword->string
    4. string->keyword

Module (chicken keyword)

Keywords are written like symbols, but prefixed with #:. They evaluate to themselves. While they behave a lot like symbols in that they are interned when read and can be compared in constant time with eq?, they are a distinct type. In particular, they have no plist, they cannot be bound or assigned to and aren't eq? to a symbol with the same spelling. Procedures can use keywords to accept optional named parameters in addition to normal required parameters.

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.

There is also a srfi-88 or (srfi 88) module which only includes the standard procedures from the SRFI document, without the CHICKEN extensions. (chicken keyword) offers the complete set of procedures, both CHICKEN-specific and standard 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


[procedure] (keyword? X)

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


[procedure] (keyword->string KEYWORD)

Transforms KEYWORD into a string.


[procedure] (string->keyword STRING)

Returns a keyword with the name STRING.

Previous: Module (chicken irregex)

Next: Module (chicken load)