[Top][All Lists]

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

Re: [Chicken-users] extras.scm: make-output-port wise or not?

From: felix
Subject: Re: [Chicken-users] extras.scm: make-output-port wise or not?
Date: Sun, 05 Jan 2003 23:26:42 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020529

Joerg F. Wittenberger wrote:
Hi all,

I came across the definition of make-output-port in extras.scm; there
I found:

(define make-output-port
         port 2
         (lambda (op port args)
           (case op
             [(#:close-output-port) (close)]
             [(#:flush-output) #f]
             [(#:write-char) (write (string args))]
             [(#:write-string) (write (string-copy args))]

Is this really wise to copy the string here?  I understand that the
'write' operation could - in theory - modify it's argument.  But I'd
argue that this should be forbidden by policy (i.e., documented as
beeing an error if it does; the result may be unspecified).  Copying
the string seems a silly prise to pay here.

That's true. I'll fix this.

             [(#:close-input-port #:char-ready? #:read-char #:peek-char)
              (unsup op) ]
             [(#:data) data]

BTW: what is this operation good for?

             [else ##sys#snafu] ) ) )
        port) ) ) )

That's a magic value returned to the caller of the handler
procedure (the procedure in slot #2 of a port record). It
tells the caller that this operation is not implemented, and
should be handled by the default handler.


reply via email to

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