[Top][All Lists]

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

Re: Input only readline port

From: Neil Jerram
Subject: Re: Input only readline port
Date: 15 Jan 2001 20:00:02 +0000

>>>>> "Dirk" == Dirk Herrmann <address@hidden> writes:

    Dirk> On 15 Jan 2001, Marius Vollmer wrote:
    >> I think I meant something like this: People might assume that
    >> (current-input-port) is connected to a tty and treat it as the
    >> `current terminal port' and use it both for input and output.
    >> They are not be aware that it really is a readline port.
    >> *Shrug*, I don't know if I'm convinced by this argument, but I
    >> don't see a need to change the existing practice, either.

    Dirk> IMO it is a bug to assume that (current-input-port) can be
    Dirk> used for output as well.  If there is the possibility that
    Dirk> people might follow such an argument, we should follow
    Dirk> Neil's suggestion and make such a misuse impossible.
    Dirk> Otherwise we will one day _have_ to keep things the broken
    Dirk> way, just because "there is so much code out there that
    Dirk> would get broken".  Better keep people from producing broken
    Dirk> code right from the start.

I've done a little more investigation...  The current behaviour really
is quite strange: if the readline port is used for output, the output
actually goes to the value of (current-output-port) at the time of the
output call.  For example... (with readline activated)

guile> (define (testp obj)
...      (call-with-output-string
...        (lambda (port)
...          (let ((normal-output (current-output-port)))
...            (set-current-output-port port)
...            (display obj (current-input-port))
...            (set-current-output-port normal-output)))))
guile> (define result (testp "hello"))
guile> result

So any assumption that output to the readline port would end up in the
same sort of place as the readline console, is broken.

One more argument: when readline is not activated...

guile> (current-input-port)
#<input: standard input /dev/pts/1>
guile> (current-output-port)
#<output: standard output /dev/pts/1>
guile> (display "hello\n" (current-input-port))
standard input:6:1: In procedure display in expression (display "hello
" (current-input-port)):
standard input:6:1: Wrong type argument in position 2: #<input: standard input 
ABORT: (wrong-type-arg)

So consistency with the non-readline case also suggests that the
readline port should be input only.


reply via email to

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