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

Echo streams in allegro-4.0



    Date: Fri, 20 Dec 1991 02:56 EST
    From: hans@cs.Buffalo.EDU (Hans Chalupsky)

    Hi,

    I wrote some code that reads input from a file and echoes it to the
    terminal using an echo stream. When I tried to port it to our Allegro
    platform I ran into the problem that Allegro-4.0.1 seems to echo some
    characters twice (see script at the end of the message).
    Do I make too strong assumptions about echo streams, or is this simply
    a bug? 

    Thanks for any help,

    Hans

    hans@cs.buffalo.edu
    Hans Chalupsky, Dept. of CS, 329 Bell Hall, SUNY@Buffalo, NY 14260.

    -------------- Echo stream script --------------

    2 (vodalus) > more echo-lists.lisp
    (a little list)

    (another little list)
 
    3 (vodalus) > acl
    Allegro CL 4.0.1 [Sun4] (2/8/91)
    Copyright (C) 1985-1991, Franz Inc., Berkeley, CA, USA
    <cl> (setq s (open "echo-lists.lisp" :direction :input))

    #<EXCL::CHARACTER-INPUT-FILE-STREAM @ #x630df6> 
    <cl> (setq es (make-echo-stream s *standard-output*))

    #<ECHO-STREAM @ #x641466> 
    <cl> (read es)                ;; Note the extra ) in the echo
    (a  little  list))

    (A LITTLE LIST) 
    <cl> (read es)                ;; and again

    (another  little  list))

    (ANOTHER LITTLE LIST) 
    <cl> (close s)

    T 
    <cl> 

This is due to the lookahead that the reader has to do to detect the end
of the symbol tokens.  See p.514 of CLtL2, the fourth and fifth bullet
items in step 8 of the reader algorithm, where it says that the
character that terminates the token must be unread, and then the
recursive call (which is reading the symbol) to READ returns.  The outer
call to READ (the one that is reading the list) then rereads the
character, causing it to be echoed again.

X3J13 has tightened up the definition of UNREAD-CHAR and PEAK-CHAR with
respect to echo streams, precisely to make the above work as you
expected.  CLtL2 and the ANSI CL draft spec say that UNREAD-CHAR should
arrange that the character not be echoed when it is reread, and
PEEK-CHAR shouldn't echo the character at all (see p.573-4 of CLtL2).
Apparently Franz hasn't implemented this yet.

                                                barmar