chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] make-output-port


From: Felix Winkelmann
Subject: Re: [Chicken-users] make-output-port
Date: Wed, 15 Jan 2003 09:44:22 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.0) Gecko/20020530

Joerg F. Wittenberger wrote:
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


This looks reasonable. I'll fix put this into CVS tonight.
Thanks.

cheers,
felix

--
address@hidden
http://www.proxima-mt.de





reply via email to

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