
Next: Filesystem Utilities
Up: Ports
Previous: File Ports
Ports with arbitrary control procedures are created with
make-input-port and make-output-port:
- (make-input-port getc char-ready? close)
creates an input port. The getc argument must be a procedure
that takes no arguments and returns the next input character from the
port. (If a non-character and non-eof value is returned, the
exn:i/o:user-port exception is raised.) The char-ready? argument must be
a procedure that takes no arguments and returns a true value if a
character is ready to be read or #f otherwise. The close
argument must a procedure of no arguments; it is called when the port
is closed.
- (make-output-port write close) creates an output
port. Write must be a procedure that takes a string and writes it.
Close must be a procedure of no arguments; it is called
when the port is closed.
Ports created by make-input-port and make-output-port are
immediately open for reading or writing. If the close procedure
does not have any side-affects, then the custom port does not need to
be explicitly closed.
PLT