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

Confusion with peek-char and char-ready




Regarding the question of the interaction between PEEK-CHAR,
CHAR-READY?, and input editing, I think we should first check to see
what the Common Lisp cleanup committee has figured out; I know they
have considered this problem, and there's no sense in us reinventing
the wheel if they've figured out something reasonable.  Could someone
out there who follows cl-cleanup stuff investigate for us?

The main reason I would like to see PEEK-CHAR in Scheme is so that it
becomes possible to write something like READ in a portable way.  READ
has the property, not explicitly stated but I believe assumed, that if
the file contains "foo)" and you do READ followed by READ-CHAR, you
get the symbol FOO and the character #\).  In order to write READ, you
have to have a way to determine whether you have arrived at the end of
a symbol, number, etc. either by hitting a delimiter or by hitting end
of file.  The definition of PEEK-CHAR or any replacement for it should
be whatever it has to be to support this application.

Perhaps we don't need the full generality of PEEK-CHAR to get this
functionality, though.  E.g. if the language had something like C
Scheme's character sets, we could have READ-CHAR-IF-IN-CSET, which
would read a character if it was among a given set and return #f
otherwise.  I'm not proposing this, just mentioning it to point out
that there may be alternatives that don't get us into as much trouble.