Marc and others,<div><br></div><div>I'm having a bit of trouble integrating proper output handling in swank-gambit. Gambit's special REPL ports (repl-input-port and repl-output-port) conflicts with what we want to do since SLIME is handling the REPL now and makes things difficult.</div>
<div><br></div><div>For example, when I eval code in swank-gambit, it does something like this:</div><div><br></div><div><div>(let ((result #f))</div><div> (let ((output (with-output-to-string ""</div><div> (set! result (eval form)))))</div>
<div> ...))</div><div><br></div><div>Yes, it's a bit awkward because I want both the output and the result for the evaluation. So we capture any output from the evaluation in the `output` variable so that we can send it to SLIME.</div>
<div><br></div><div>The problem is that `pp` by default prints to `repl-output-port`. `repl-output-port` is not a dynamic variable; it is a hardcoded special port. So I cannot in any way capture its output when I'm evaluating forms, unless users specifically pass `current-output-port` to `pp` as the port, which is confusing.</div>
<div><br></div><div>Now, I have successfully redirected the repl ports to the current ports with the following code:</div><div><br></div><div><div>(define (thread-make-swank-repl-channel thread)</div><div> (##make-repl-channel-ports (current-input-port)</div>
<div> (current-output-port)))</div><div><br></div><div><br></div><div>(set! ##thread-make-repl-channel</div><div> thread-make-swank-repl-channel)</div><div><br></div><div>This lets me capture anything to `repl-output-port` because it sends it to `current-output-port`. However, now we have a problem. Any thread *outside* of SLIME evaluations (say, any part of the application we are debugging) needs to have different behavior. If a slime client is connected, I think all output from an application should be redirected to SLIME in some fashion, and this could be done by overriding ##thread-make-repl-channel.</div>
<div><br></div><div>The solution is to set ##thread-make-repl-channel to create ports which forward output to a SLIME connect if connected. But when I'm evaluating code sent from SLIME, I want to capture the output sent to `repl-output-port`, so I want to treat it as a dynamic variable like so:</div>
<div><br></div><div><div>(let ((result #f))</div><div> (let ((output (with-output-to-string ""</div><div> (parameterize ((repl-output-port (current-output-port)))</div><div> (set! result (eval form))))))</div>
<div> ...))</div></div><div><br></div><div>Either we need to rethink that fact that `pp` sends output to `repl-output-port` by default, treat `repl-output-port` as a dynamic variable, or do something to make all this clearer. It's very confusing.</div>
<div><br></div><div>- James</div><div><br></div></div></div>