chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] make-output-port


From: Joerg F. Wittenberger
Subject: [Chicken-users] make-output-port
Date: 14 Jan 2003 21:09:15 +0100

Hi Felix,

I'm in trouble with the custom ports definitions.  I _need_ to control
when the output is flushed but make-output-port supports only (write
<string>) and (close) could this modification go into extras.scm?
(Anybody who'd object please speak up ASAP).

(define make-output-port
  (let ([string string])
    (lambda (write close . flush)
      (let ([port (##sys#make-port #f 6 #f #f)]
            [data (vector #f)] )
        (define (unsup op)
          (##sys#error "operation not supported by custom output port" port op) 
)
        (##sys#setislot port 1 #t)
        (##sys#setslot port 3 "(custom)")
        (##sys#setislot port 4 0)
        (##sys#setislot port 5 0)
        (##sys#setslot
         port 2
         (lambda (op port args)
           (case op
             [(#:close-output-port) (close)]
             [(#:flush-output) (and (pair? flush) ((car flush)))]
             [(#:write-char) (write (string args))]
             [(#:write-string) (write args)]
             [(#:close-input-port #:char-ready? #:read-char #:peek-char)
              (unsup op) ]
             [(#:data) data]
             [else ##sys#snafu] ) ) )
        port) ) ) )

Cheers

/Jörg

-- 
The worst of harm may often result from the best of intentions.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]