| I seem to be missing something on how readc and readline work. They appear to include the prior <Enter> keypress as the first character that is read. So code that is trying to read four characters: arc> (let ret "" (repeat 4 (zap + ret (readc))) ret)
Reads only two useful times: a
b
"\na\nb"
The first two lines are input lines that are concluded with the <Enter> button. 'readline works the same way: arc> (readline)
abc
"\nabc"
The newline is at the beginning of the string; I would expect the newline that I press after typing (newline) to be consumed by the repl, and the newline that I press after typing "abc" to be in the string. Obviously, I can hack the functionality I want together: arc> (def my-readc ((o port (stdin))) (readc port) (readc port))
#<procedure:zz>
arc> (my-readc)
a
#\a
But it seems like there should be a better way -- is there? |