[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Pipelining streams

Has anyone had any luck trying to 1pipeline0 streams?  Suppose that you
had a function 2foo0 that takes an input stream as an argument.  Further,
suppose you had another function 2bar0 that takes an output stream as an
argument.  For example,

(defun 2foo0 (input-stream)
  (read-and-process-stream input-stream))

(defun 2bar0 (output-stream)
  (create-garbage-and-write-to output-stream))

I'd like to be able to call a third function, 2pipeline0, that would take the
output generated by 2bar0 and send it as input to the function 2foo0.  For

(pipeline bar foo)

should do the right thing.  For now, I'm using those fake "string
streams," using macros like

(defmacro with-output-to-stream ((s) &body body)
     (with-output-to-string (,s)


(defun bad-pipeline-implementation (f1 f2)
    (with-output-to-stream (s)
      (funcall f1 s))))

However, this hack creates huge temporary strings.  In addition, it
needlessly gathers all of the output from the first function before
sending it as input to the second function.  Does anyone know of a
better way to solve this problem?  In particular, does anyone have a
solution that permits concurrent execution of the pipelined functions?