www.delorie.com/gnu/docs/guile/guile_308.html   search  
 
Buy GNU books!


Guile Reference Manual

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

27.1 Ports

[Concept of the port abstraction.]

Sequential input/output in Scheme is represented by operations on a port. Characters can be read from an input port and written to an output port. This chapter explains the operations that Guile provides for working with ports.

The formal definition of a port is very generic: an input port is simply "an object which can deliver characters on command," and an output port is "an object which can accept characters." Because this definition is so loose, it is easy to write functions that simulate ports in software. Soft ports and string ports are two interesting and powerful examples of this technique.

Scheme Procedure: input-port? x
C Function: scm_input_port_p (x)
Return #t if x is an input port, otherwise return #f. Any object satisfying this predicate also satisfies port?.

Scheme Procedure: output-port? x
C Function: scm_output_port_p (x)
Return #t if x is an output port, otherwise return #f. Any object satisfying this predicate also satisfies port?.

Scheme Procedure: port? x
C Function: scm_port_p (x)
Return a boolean indicating whether x is a port. Equivalent to (or (input-port? x) (output-port? x)).


  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003