<div dir="ltr">Is there any particular reason there's no general close-port function that works on both input ports and output ports? Would an implementation along the lines of ((if (input-port? p) close-input-port close-output-port) p) have problems that make this unreasonable? The only reason I ask is because I was writing a macro let-ports that works like let (but only for ports) that automatically closes the ports it defines. My naive implementations of these are:<div>
<br></div><div>(define (close-port p)</div><div>  ((if (input-port? p) close-input-port close-output-port) p))</div><div><br></div><div>(define-syntax-rule (let-ports ([port port-expr] ...) body ...)<br>  (let ([port port-expr] ...)<br>
    body ...<br>    (close-port port) ...))</div></div>