[Ecls-list] CLOS streams
Juan Jose Garcia-Ripoll
jlr at mpq.mpg.de
Tue Aug 27 06:56:06 UTC 2002
Since Beppe's version of ECL, this lisp interpreter has supported the
possibility of using user-defined objects as input/output streams. The
code has been reworked so that it is easier to maintain. Nevertheless
I post the following announcement so that people become aware of this
feature. I welcome any comments directed to improving this interface.
* System design:
- Global function pointer output_ch_fun and read_ch_fun
disappear. Now the differences between ordinary streams and CLOS
streams are handled in file.d. Optimizations for synonym streams
also disappear from read.d and print.d.
* Visible changes and ANSI compatibility:
- New configuration flag --with-clos-streams, enable the user to
define CLOS objects which behave as lisp streams. Such object must
have the following methods defined: STREAM-READ-CHAR,
STREAM-UNREAD-CHAR, STREAM-LISTEN, STREAM-CLEAR-INPUT,
STREAM-WRITE-CHAR, STREAM-CLEAR-OUTPUT, STREAM-FORCE-OUTPUT,
STREAM-CLOSE.
User defined streams are very straightforward to implement (See previous posts
from Andrew Topp in this list), but they can be rather slow, since
input/output is performed character-wise, without buffering.
The changes I have made are related to removing many "optimizations" in the
PRINT/READ routines. This code worked checked the input of PRINT, READ, etc,
and when it was a CLOS object, it invoked one of the method mentioned above.
This was tricky because the type of the stream and the routines to handle it
had to be kept in global pointers, which gave rise to some errors already
discussed in this list.
What I have done is to move all this code to file.d. When the user compiles
ECL using --with-clos-streams, all low level routines which read/write to
streams (not PRINT, READ, etc, but lower level functions) accept both
ordinary streams and user defined objects. This shouldn't slow the operation
with ordinary streams much, and it also makes the code more robust, since all
these low level routines now check the type of its arguments.
Juanjo
--
Max-Planck-Institut fuer Quantenoptik +49/089/32905-127
Hans-Kopfermann-Str. 1, D-85748 www.arrakis.es/~worm
Garching b. Muenchen, Germany worm at arrakis.es
More information about the ecl-devel
mailing list