Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.lisp > #60737 > unrolled thread

Connecting stream filters in CL

Started byluxhalitus <luxhalitus@null.invalid>
First post2025-11-05 10:18 +0000
Last post2026-06-22 15:50 -0400
Articles 3 — 3 participants

Back to article view | Back to comp.lang.lisp


Contents

  Connecting stream filters in CL luxhalitus <luxhalitus@null.invalid> - 2025-11-05 10:18 +0000
    Re: Connecting stream filters in CL steve g <sgonedes1977@gmail.com> - 2026-06-08 12:33 -0400
    Re: Connecting stream filters in CL steve g <Sgonedes1977@gmail.com> - 2026-06-22 15:50 -0400

#60737 — Connecting stream filters in CL

Fromluxhalitus <luxhalitus@null.invalid>
Date2025-11-05 10:18 +0000
SubjectConnecting stream filters in CL
Message-ID<8qgkeq9n.fsf@null.invalid>
I'm currently prototyping a system of multiple interconnected string
filters and am wondering what the best practices are regarding the
Common Lisp streams API.

If i had a filter function like:

| (defun number-lines (in out)
|   (handler-case
|     (loop with line = ""
|           and number = 1
|           do (setf line (read-line in))
|              (format out "~D: ~A" number line)
|              (incf number))
|     (end-of-file (e))))

how would i go about chaining two calls together?

A macro that takes advantage of the string stream types immediately
comes to mind:

| (defmacro pipe ((writing &body in) (reading &body out))
|   `(let ((,reading
|            (make-string-input-stream
| 	    (let ((,writing (make-string-output-stream)))
| 	      ,@in
| 	      (get-output-stream-string ,writing)))))
|      ,@out))

You could also write wrappers around C pipe(2) or mkfifo. None of these
seem like such a good fit for Common Lisp streams though, considering
their implementation should already come with some kind of buffering
built in. Allegro CL exposes a make-pipe-streams and a
make-function-input-stream function, but no such luck in SBCL it seems.

Any quicklisp packages featuring this exact functionality or
alternatives i'm missing?

-- 
 ,`> 
( (    
 `.>

[toc] | [next] | [standalone]


#60818

Fromsteve g <sgonedes1977@gmail.com>
Date2026-06-08 12:33 -0400
Message-ID<87tsrdm1q4.fsf@gmail.com>
In reply to#60737
luxhalitus <luxhalitus@null.invalid> writes:

> I'm currently prototyping a system of multiple interconnected string
> filters and am wondering what the best practices are regarding the
> Common Lisp streams API.


greay streams and simple stream interface would be a good place to
start.

[toc] | [prev] | [next] | [standalone]


#61010

Fromsteve g <Sgonedes1977@gmail.com>
Date2026-06-22 15:50 -0400
Message-ID<877bnqjqwq.fsf@gmail.com>
In reply to#60737
luxhalitus <luxhalitus@null.invalid> writes:

> I'm currently prototyping a system of multiple interconnected string
> filters and am wondering what the best practices are regarding the
> Common Lisp streams API.

check out simple streams, gray streams, or simple streams.

A very simple soution is to call your program and the out output as a
single file; then suckit up with lisp read. using 

sb-ext:run-program

 this is not the most elegant solution but it works very easily.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.lisp


csiph-web