(sph io path-pipe-chain)

call procedures with input/output arguments in a chained manner to allow data flow between them.

library description

procedures can be configured to take paths or ports as arguments and the links are made compatible automatically

import name

(sph io path-pipe-chain)





first-input last-output config ... ->

string/port/any string/port/any #(symbol symbol procedure:{string/port string/port -> any}) ... -> (any ...)

first-input last-output (path/port/nothing path/port/nothing procedure:{in out -> result}) ... -> (result ...)


like pipe-chain but additionally supports specifying the type of port between procedures.

procedures can take file paths or ports for input or output. input output combinations between procedures are automatically made compatible.


* in port-path and path-port links, input or output are not ports but procedures that return

the path that has to be opened for read or write in a separate thread or process.

it blocks until the next procedure has opened the other end. this is typical behaviour of

named pipes and there does not seem to be any applicable way around it

* intermediate ports must be closed after read/write finished

* intermediate named pipe paths should be deleted after read/write finished. otherwise they accumulate

in the systems temporary directory (but do not take up space in the filesystem)

* ports are not automatically closed when an exception occurs

* to make it possible to read while a previous procedure is writing a user might want to create threads or processes

* named pipes are used when paths are requested. they normally block for each end until the other end is connected,

and they do not send end of file before the writer is closed

most of these caveats are to keep this procedure generic enough to be useful in many situations

usage example:

(path-pipe-chain "/tmp/test" (current-output-port) (vector (q nothing) (q port) (l (in out) (file->port in out))) (vector (q path) (q port) (l (in out) (do-stuff path port))))



tags: programming guile documentation library scheme sph-lib q1 computer highlight pipe port sph-io-path-pipe-chain