manpagez: man pages & more
info guile
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.17.2 Reading Scheme Code

Scheme Procedure: read [port]
C Function: scm_read (port)

Read an s-expression from the input port port, or from the current input port if port is not specified. Any whitespace before the next token is discarded.

The behaviour of Guile’s Scheme reader can be modified by manipulating its read options.

Scheme Procedure: read-options [setting]

Display the current settings of the read options. If setting is omitted, only a short form of the current read options is printed. Otherwise if setting is the symbol help, a complete options description is displayed.

The set of available options, and their default values, may be had by invoking read-options at the prompt.

scheme@(guile-user)> (read-options)
(square-brackets keywords #f positions)
scheme@(guile-user)> (read-options 'help)
copy              no    Copy source code expressions.
positions         yes   Record positions of source code expressions.
case-insensitive  no    Convert symbols to lower case.
keywords          #f    Style of keyword recognition: #f, 'prefix or 'postfix.
r6rs-hex-escapes  no    Use R6RS variable-length character and string hex escapes.
square-brackets   yes   Treat `[' and `]' as parentheses, for R6RS compatibility.
hungry-eol-escapes no   In strings, consume leading whitespace after an
                        escaped end-of-line.

The boolean options may be toggled with read-enable and read-disable. The non-boolean keywords option must be set using read-set!.

Scheme Procedure: read-enable option-name
Scheme Procedure: read-disable option-name
Scheme Syntax: read-set! option-name value

Modify the read options. read-enable should be used with boolean options and switches them on, read-disable switches them off.

read-set! can be used to set an option to a specific value. Due to historical oddities, it is a macro that expects an unquoted option name.

For example, to make read fold all symbols to their lower case (perhaps for compatibility with older Scheme code), you can enter:

(read-enable 'case-insensitive)

For more information on the effect of the r6rs-hex-escapes and hungry-eol-escapes options, see (see section String Read Syntax).


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on February 3, 2012 using texi2html 5.0.