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

Re: (read) reads an s-exp without Return

The simple answer to your question is to do:
(read-from-string (read-line)).
But that will only read the first form on the line, if the possibility
exists that the user will enter multiple forms before typing the
carriage return, then you will need to do something more complicated.
It also ties up the system waiting for someone to type in a line.  You
probably will want to drop to a lower level yet and read one character
at a time from the input stream using something like the common lisp
function (read-char-no-hang) {p. 380 in Steele's book}.

The top-level code that I sent to you does wait for a carriage return
before returning the form that was read.  However, I presume that you
want to replace the read-form function with one of your own so that you
can also have your own prompt.  You will need to many additional things
to duplicate everything that read-form does.  For example, you will need
to set the global variables *, **, ***, +, ... ,/, ... ,-. You will also
need to call (get-next-queued-form) {see p. 320 in the MACL manual} to
support the eval-enqueue mechanism.  There may be other things as well
that I have not thought about.  

Good luck!  Paul (plkrueger@serc.3m.com)