You need to pass the current *standard-output* to the new stream somehow, and then in this stream function you can bind *standard-output* to this value.
Current common Lisp implementations create streaming local dynamic bindings, and SBCL is one of them .
(sb-thread:make-thread ;; thread function #'(lambda (standard-output) ;; thread-local dynamic binding of special variable (let ((*standard-output* standard-output)) ...)) ;; thread function argument, provided by the current thread :arguments (list *standard-output*))
Note that I could name the argument to the stream function *standard-output* , and then I would not need let , since the dynamic binding was done while writing the function. But I think that dynamic bindings should be explicit and obvious, despite the fact that it has special naming conventions.
source share