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

6.18.1 Ports

Builtin Class: <port>
A port class. A port is Scheme's way of abstraction of I/O channel. Gauche extends a port in number of ways so that it can be used in wide range of applications.

Standard Scheme (R5RS) essentially defines a port as an entity that you can fetch a character at a time and look one character ahead from an input port, and put a character at a time to an output port. Other R5RS I/O routines can be built on top of them.

Besides this basics, Gauche's port can handle the following opertaions.

Byte I/O
You can read/write one byte at a time, instead of a character. (Remember, Gauche handles multibyte characters, so a character may be consisted from more than one bytes). Most ports allow you to mix byte I/O and character I/O, if needed.

Block I/O
You can read/write a specified number of byte sequences. This can be an efficient way of moving block of data, if the port's underlying implementation supports block I/O operation (for example, if the underyling port is a unix buffered stream, this operation uses fread or fwrite).

Some ports can be used to convert a data stream from one format to another; one of such applications is character code conversion ports, provided by gauche.charconv module (See section 9.2 gauche.charconv - Character Code Conversion, for details). You can define a procedural ports, in both Scheme and C, to implement other functionality.

This document was generated by Ken Dickey on November, 28 2002 using texi2html