Re: portable way to define new stream classes?

From: Steven M. Haflich (smh_no_spiced_ham_at_alum.mit.edu)
Date: 02/21/05


Date: Mon, 21 Feb 2005 04:45:30 GMT

Frank Buss wrote:

> I use a framework, which expects streams. But sometimes I need
> in-memory streams, because I don't want to create temporary files.
> In Lispworks I can define my own stream classes (see below), but how can
> I implement this in Common Lisp?

Most implementations provide a way customize streams, including defining
new suibclasses of stream, because they find this capability necessary
themselves. But to answer your question strictly, there is no way you
can define customized stream classes in portable Common Lisp. The class
stream might in some implementation be of metaclass built-in-class,
and there is no portable way to customize a built-in-class.

Encapsulation can nearly solve the problem, as you suggest, but the
solution could be tedious. You probably won't be able to pass your
encapsulated stream object to other portable code that might examine
the stream object, since it won't satisfy the streamp predicate.
Also there are a lot of places where streams have extraneous semantics,
such as when a stream is passed to the pathname function.