Warning: This is the manual of the legacy Guile 2.0 series. You may want to read the manual of the current stable series instead.

Next: , Previous: , Up: Read/Load/Eval/Compile   [Contents][Index]


6.17.3 Writing Scheme Values

Any scheme value may be written to a port. Not all values may be read back in (see Scheme Read), however.

Scheme Procedure: write obj [port]

Send a representation of obj to port or to the current output port if not given.

The output is designed to be machine readable, and can be read back with read (see Scheme Read). Strings are printed in double quotes, with escapes if necessary, and characters are printed in ‘#\’ notation.

Scheme Procedure: display obj [port]

Send a representation of obj to port or to the current output port if not given.

The output is designed for human readability, it differs from write in that strings are printed without double quotes and escapes, and characters are printed as per write-char, not in ‘#\’ form.

As was the case with the Scheme reader, there are a few options that affect the behavior of the Scheme printer.

Scheme Procedure: print-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 print-options at the prompt.

scheme@(guile-user)> (print-options)
(quote-keywordish-symbols reader highlight-suffix "}" highlight-prefix "{")
scheme@(guile-user)> (print-options 'help)
highlight-prefix          {       The string to print before highlighted values.
highlight-suffix          }       The string to print after highlighted values.
quote-keywordish-symbols  reader  How to print symbols that have a colon
                                  as their first or last character. The
                                  value '#f' does not quote the colons;
                                  '#t' quotes them; 'reader' quotes them
                                  when the reader option 'keywords' is
                                  not '#f'.
escape-newlines           yes     Render newlines as \n when printing
                                  using `write'. 
r7rs-symbols              no      Escape symbols using R7RS |...| symbol
                                  notation.

These options may be modified with the print-set! syntax.

Scheme Syntax: print-set! option-name value

Modify the print options. Due to historical oddities, print-set! is a macro that expects an unquoted option name.


Next: , Previous: , Up: Read/Load/Eval/Compile   [Contents][Index]