| [ << ] | [ < ] | [ 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 global 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.
curly-infix no Support SRFI-105 curly infix expressions.
Note that Guile also includes a preliminary mechanism for setting read
options on a per-port basis. For instance, the case-insensitive
read option is set (or unset) on the port when the reader encounters the
#!fold-case or #!no-fold-case reader directives.
Similarly, the #!curly-infix reader directive sets the
curly-infix read option on the port, and
#!curly-infix-and-bracket-lists sets curly-infix and
unsets square-brackets on the port (see section SRFI-105 Curly-infix expressions.). There is
currently no other way to access or set the per-port read options.
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-enableshould be used with boolean options and switches them on,read-disableswitches 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 April 20, 2013 using texi2html 5.0.
