guile-devel
[Top][All Lists]
Advanced

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

Re: Proposed change to `make-readline-port'


From: Dirk Herrmann
Subject: Re: Proposed change to `make-readline-port'
Date: Sun, 4 Mar 2001 14:18:10 +0100 (MET)

On 4 Mar 2001, Neil Jerram wrote:

> How about `make-buffered-input-port' and `(ice-9 buffered-input)'?
> 
> Rationale...  I realized after further thinking that (i) this
> procedure basically does buffering, and in fact neither assumes nor
> expects that the input chunks will be complete lines terminated by a
> newline character; (ii) we should probably emphasize that the module
> only applies to input, and not output.

I like that.  However, it seems that the implementation that you have
posted was indeed line buffering oriented, at least that's basically what
the part
  (cond ...
        ((>= string-index (string-length read-string))
         (begin
           (set! string-index -1)
           #\nl))
        ...)
indicates.  (BTW:  No wrapping with begin is necessary for 'cond'
clauses).  And, with respect to the definition of the reader procedure
that is passed to make-buffered-input-port:  I suggest not to pass this
procedure a boolean parameter.  If I see it right, this parameter could
easily be avoided if the reader procedure itself stores some local state,
for example:
  (define (make-example-line-port)
    (make-line-port (let* ((continuation? #f))
                      (lambda ()
                        (display (if continuation?
                                     "... "
                                     "New read: "))
                        (set! continuation? #t)
                        (force-output)
                        (read-line)))))
A similar approach can be taken in boot-9.scm.  This avoids the use of
object properties.

Best regards,
Dirk Herrmann





reply via email to

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