manpagez: man pages & more
info guile
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [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 section Reading Scheme Code), 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 section Reading Scheme Code). 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'. 

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.


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

This document was generated on April 20, 2013 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.