| port?(3scm) | Scheme Programmer's Manual | port?(3scm) |
NAME
port?, input-port?, output-port? - test for ports and their directionLIBRARY
(import (rnrs)) ;R6RS (import (rnrs io ports)) ;R6RS (import (rnrs io simple)) ;R6RS, except port? (import (scheme base)) ;R7RS (import (scheme r5rs)) ;R7RS, except port?
SYNOPSIS
(port? obj) (input-port? obj) (output-port? obj)
DESCRIPTION
The port? procedure returns #t if the argument is a port, and #f otherwise.The input-port? procedure returns #t if the argument is an input port (or a combined input and output port), and #f otherwise.
The output-port? procedure returns #t if the argument is an output port (or a combined input and output port), and #f otherwise.
RETURN VALUES
Returns a single boolean object.EXAMPLES
(port? (current-output-port)) => #t (port? 'not-a-port) => #f (input-port? (current-input-port)) => #t (output-port? (current-output-port)) => #t (input-port? (current-output-port)) => #f
COMPATIBILITY
The port? procedure is new in R6RS and new in R7RS. The input-port? and output-port? procedures also accept combined input/output ports.ERRORS
This procedure can raise exceptions with the following condition types:- &assertion (R6RS)
- The wrong number of arguments was passed.
- R7RS
- The assertions described above are errors. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.
SEE ALSO
textual-port?(3scm), input-port-open?(3scm), current-input-port(3scm)STANDARDS
R4RS, IEEE Scheme, R5RS, R6RS, R7RSHISTORY
The input-port? and output-port? procedures first appeared in R2RS.AUTHORS
This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://weinholt.se/scheme/manpages/.| 2026-07-22 |