Next: , Previous: Printing Scheme, Up: Printing Scheme

4.12.1 Generic-Write

(require 'generic-write) generic-write is a procedure that transforms a Scheme data value (or Scheme program expression) into its textual representation and prints it. The interface to the procedure is sufficiently general to easily implement other useful formatting procedures such as pretty printing, output to a string and truncated output.

— Procedure: generic-write obj display? width output
Scheme data value to transform.
Boolean, controls whether characters and strings are quoted.
Extended boolean, selects format:
single line format
integer > 0
pretty-print (value = max nb of chars per line)

Procedure of 1 argument of string type, called repeatedly with successive substrings of the textual representation. This procedure can return #f to stop the transformation.

The value returned by generic-write is undefined.


          (write obj) == (generic-write obj #f #f display-string)
          (display obj) == (generic-write obj #t #f display-string)


          display-string ==
          (lambda (s) (for-each write-char (string->list s)) #t)