[previous] [up] [next]     [contents] [index]
Next: Customizing Read Up: Ports Previous: Custom Ports

Reading and Printing

In addition to the standard reading procedures, MzScheme provides read-line, read-string, and read-string!:

In addition to the standard printing procedures, MzScheme provides print, which outputs values to a port by calling the port's print handler (see section 11.1.9):

The print procedure is used to print Scheme values in a context where a programmer expects to see a Scheme value. The rationale for providing print is that display and write both have standard output conventions, and this standardization restricts the ways that an environment can change the behavior of these procedures. No output conventions should be assumed for print so that environments are free to modify the actual output generated by print in any way. Unlike the port display and write handlers, a global port print handler can be installed through the global-port-print-handler parameter (see section 9.4.1.2).

Formatted output is written to a port with fprintf:

When an illegal format string is supplied to one of these procedures, the exn:application:type exception is raised. When the format string requires more additional arguments than are supplied, the exn:application:fprintf:no-argument exception is raised. When more additional arguments are supplied than are used by the format string, the exn:application:fprintf:extra-arguments exception is raised.

For example,

  (fprintf port "~a as a string is ~s.~n" '(3 4) "(3 4)") 
prints this message to port:[footnote]
  (3 4) as a string is "(3 4)". 
followed by a newline.


[previous] [up] [next]     [contents] [index]
Next: Customizing Read Up: Ports Previous: Custom Ports

PLT