Ports represent character-oriented input/output devices.
<port> | (<seq>) | C |
open | (t|(t< <port>) x|<str> => <port>) | G |
| creates port given port specific spec x. | |
close | (x|<port>) | G |
| closes and cleanups port. | |
| (x|<port>) | M |
| noop default. | |
WITH-PORT | (WITH-PORT (,name ,port) ,@body) | S |
| binds ,name to the value of ,port
during the evaluation of (seq ,@body) and finally
ensures that the port is closed at the end of evaluation. | |
eof-object? | (x|<chr> => <log>) | G |
<in-port> | (<port>) | C |
| input port. | |
in | <in-port> | I |
| standard input. | |
get | (x|<in-port> => <chr>) | G |
| returns next available character or eof-object. | |
gets | (x|<in-port> => <str>) | G |
| returns a line until either reading a newline or eof-object. | |
peek | (x|<in-port> => <chr>) | G |
| returns next available character if any without advancing
pointer or eof-object. | |
ready? | (x|<in-port> => <log>) | G |
| returns true iff a character is available. | |
<out-port> | (<port>) | C |
| output port. | |
out | <out-port> | I |
| standard output. | |
force-out | (x|<out-port>) | G |
| ensures that buffers are forced and pending output is completed. | |
put | (x|<out-port> e|<chr>) | G |
| outputs a single character. | |
puts | (x|<out-port> e|<str>) | G |
| outputs string. | |
newline | (x|<out-port>) | G |
| outputs a newline sequence. | |
say | (x|<out-port> args|...) | G |
| == (do (op puts x (to-str _)) args) | |
|
File ports are ports which map to files.
String ports provide port interface mapped onto strings.
<str-port> | (<any>) | C |
port-contents | (x|<str-port> => <str>) | P |
| returns underlying string. | |
<str-in-port> | (<str-port> <out-port>) | C |
open | (t|(t= <str-in-port>) dat|<str> => <str-in-port>) | M |
| creates string in port mapped to string dat. | |
port-index | (x|<str-port> => <int>) | P |
| returns index from which next character will be read. | |
<str-out-port> | (<str-port> <in-port>) | C |
open | (t|(t= <str-out-port>) dat|<str> => <str-out-port>) | M |
| creates string out port mapped to string dat. | |
PORT-TO-STR | (PORT-TO-STR ,name ,@body) | S |
| == (let ((,name (open <str-out-port> ""))) ,@body (port-contents ,name)) | |
|