Next: Constructors and Accessors for Ports, Previous: Port Primitives, Up: Port Primitives
The procedures in this section provide means for constructing port types with standard and custom operations, and accessing their operations.
Creates and returns a new port type. Operations must be a list; each element is a list of two elements, the name of the operation (a symbol) and the procedure that implements it. Port-type is either
#f
or a port type; if it is a port type, any operations implemented by port-type but not specified in operations will be implemented by the resulting port type.Operations need not contain definitions for all of the standard operations; the procedure will provide defaults for any standard operations that are not defined. At a minimum, the following operations must be defined: for input ports,
read-char
andpeek-char
; for output ports, eitherwrite-char
orwrite-substring
. I/O ports must supply the minimum operations for both input and output.If an operation in operations is defined to be
#f
, then the corresponding operation in port-type is not inherited.If
read-char
is defined in operations, then any standard input operations defined in port-type are ignored. Likewise, ifwrite-char
orwrite-substring
is defined in operations, then any standard output operations defined in port-type are ignored. This feature allows overriding the standard operations without having to enumerate them.
These predicates return
#t
if object is a port type, input-port type, output-port type, or I/O-port type, respectively. Otherwise, they return#f
.
Returns a newly allocated list containing all of the operations implemented by port-type. Each element of the list is a list of two elements — the name and its associated operation.