1. Extensions to the R5RS standard
    1. Identifiers
    2. Brackets and braces
    3. Non-standard procedures and syntax
    4. User defined character names
    5. Special characters in strings
  2. Non-standard read syntax
    1. Escapes in symbols
    2. Multiline Block Comment
    3. Expression Comment
    4. External Representation
    5. Location Expression
    6. Blob literals
    7. Keyword
    8. Multiline String Constant
    9. Multiline String Constant with Embedded Expressions
    10. Foreign Declare
    11. String escape sequences
    12. Bang
    13. Case Sensitive Expression
    14. Case Insensitive Expression
    15. Conditional Expansion

Extensions to the R5RS standard


Identifiers may contain special characters if delimited with | ... |.

Brackets and braces

The brackets [ ... ] and the braces { ... } are provided as an alternative syntax for ( ... ). A number of reader extensions is provided.

Non-standard procedures and syntax

CHICKEN provides numerous non-standard procedures. See the manual sections on the included library modules (Included modules) for more information.

User defined character names

User defined character names are supported. See char-name. Characters can be given in hexadecimal notation using the #\xXX syntax where XX specifies the character code. Character codes above 255 are supported and can be read (and are written) using the #\uXXXX and #\UXXXXXXXX notations.

Non-standard characters names supported are #\tab, #\linefeed, #\return, #\alarm, #\vtab, #\nul, #\page, #\esc, #\delete and #\backspace.

Special characters in strings

CHICKEN supports special characters preceded with a backslash \ in quoted string constants. \n denotes the newline-character, \r carriage return, \b backspace, \t TAB, \v vertical TAB, \a alarm, \f formfeed, \xXX a character with the code XX in hex and \uXXXX (and \UXXXXXXXX) a unicode character with the code XXXX. The latter is encoded in UTF-8 format.

Non-standard read syntax

Escapes in symbols

| ... | may be used to escape a sequence of characters when reading a symbol. \X escapes a single character in a symbols name:

 (symbol->string '|abc def|)       =>   "abc def"
 (symbol->string '|abc||def|)      =>   "abcdef"
 (symbol->string '|abc|xyz|def|)   =>   "abcxyzdef"
 (symbol->string '|abc\|def|)      =>   "abc|def"
 (symbol->string 'abc\ def)        =>   "abc def"

Multiline Block Comment

[read] #|
#| ... |# 

A multiline block comment. May be nested. Implements SRFI-30.

Expression Comment

[read] #;

Treats EXPRESSION as a comment. That is, the comment runs through the whole S-expression, regardless of newlines, which saves you from having to comment out every line, or add a newline in the middle of your parens to make the commenting of the last line work, or other things like that. Implements SRFI-62.

External Representation

[read] #,

Allows user-defined extension of external representations. (For more information see the documentation for SRFI-10)

Location Expression


An abbreviation for (location EXPRESSION).

Blob literals

[read] #${
 #${ HEX ... }

Syntax for literal "blobs" (byte-sequences). Expects hexadecimal digits and ignores any whitespace characters:

 #;1> ,d '#${deadbee f}
 blob of size 4:
    0: de ad be ef                                     ....


[read] #:

Syntax for keywords. Keywords are symbols that evaluate to themselves, and as such don't have to be quoted. Either SYMBOL: or :SYMBOL is accepted, depending on the setting of the keyword-style parameter, but never both. #:SYMBOL is always accepted.

Multiline String Constant

[read] #<<

Specifies a multiline string constant. Anything up to a line equal to TAG (or end of file) will be returned as a single string:

(define msg #<<END
 "Hello, world!", she said.

is equivalent to

(define msg "\"Hello, world!\", she said.")

Multiline String Constant with Embedded Expressions

[read] #<#

Similar to #<<, but allows substitution of embedded Scheme expressions prefixed with # and optionally enclosed in curly brackets. Two consecutive #s are translated to a single #:

(define three 3)
(display #<#EOF
This is a simple string with an embedded `##' character
and substituted expressions: (+ three 99) ==> #(+ three 99)
(three is "#{three}")


This is a simple string with an embedded `#' character
and substituted expressions: (+ three 99) ==> 102
(three is "3")

Foreign Declare

[read] #>
#> ... <#

Abbreviation for (foreign-declare " ... ").

String escape sequences

String-literals may contain the following escape sequences:

Escape sequence Character
\n line feed / newline
\t tab
\r carriage return
\b backspace
\a bell
\v vertical tab
\f form feed
\xXX hexadecimal 8-bit character code
\uXXXX hexadecimal 16-bit Unicode character code
\UXXXXXXXX hexadecimal 32-bit Unicode character code
\OOO octal 8-bit character code
\|   \"    \\    \' the escaped character


[read] #!

Interpretation depends on the directly following characters. Only the following are recognized. Any other case results in a read error.

Line Comment
If followed by whitespace or a slash, then everything up the end of the current line is ignored
Eof Object
If followed by the character sequence eof, then the (self-evaluating) end-of-file object is returned
DSSSL Formal Parameter List Annotation
If followed by any of the character sequences optional, rest or key, then a symbol with the same name (and prefixed with #!) is returned
Read Mark Invocation
If a read mark with the same name as the token is registered, then its procedure is called and the result of the read-mark procedure will be returned

Case Sensitive Expression

[read] #cs

Read the next expression in case-sensitive mode (regardless of the current global setting).

Case Insensitive Expression

[read] #ci

Read the next expression in case-insensitive mode (regardless of the current global setting).

Conditional Expansion

[read] #+

Rewrites to

(cond-expand (FEATURE EXPR) (else))

and performs the feature test at macroexpansion time. Therefore, it may not work as expected when used within a macro form.

Previous: Deviations from the standard

Next: Included modules