From: stktrc <stktrc at yahoo com>
Subject: Re: run/port for input
Date: 07 Nov 2003 10:28:54 +0100
Message-ID: <i563cd0sf1l.fsf at mao acc umu se>
ZHAO Wei <zhaoway at public1 ptt js cn> writes:
> Can I have something as nice as (run/port ...) but for input instead
> of for output? Thank you!
Below is a modification of run/port taken from the SCSH sources to
produce an input port instead.
(define (run/inport* thunk)
(receive
(r w) (pipe)
(fork (lambda ()
(close w)
(move->fdes r 0)
(with-current-input-port* r thunk)))
(close r)
w))
(define-syntax run/inport
(syntax-rules ()
((_ . epf) (run/inport* (lambda () (exec-epf . epf))))))
Up |