Best way to figure it out is to try it in this case

- Code: Select all
CL->USER> (read-line)
yup it is a string
"yup it is a string"
nil
You can coerce a string to a list with (coerce string 'list), but that'd be a list of characters, of course.
I think you might want to use READ which reads one s-expression with the same rule as code is read.
- Code: Select all
(defun read-until-empty (stream)
"Does what you want, but from a stream."
(let ((result (read stream nil :eof)))
(if (eql result :eof) nil ;End of stream, done.
(cons result (read-until-empty stream))))) ;Keep listing results.
(defun read-until-empty-from-string (string)
"Makes it work from a stream for you."
(with-input-from-string (stream string)
(read-until-empty stream)))
(read-until-empty-from-string "reads symbols (but also lists) and numbers 1 2 3")
Streams can be very useful even if you're not working with files! For instance if you want to compose a string, you can similarly use with-output-to-string; otherwise you'd be effectively reimplementing streams.
Note that it also reads numbers and sublists and such which can be undesirable. CL does seem a little annoying in this, it feels a way too inconvenient working with readtables/variables and such to try make READ work, and CL is lacking for instance in having parse-integer, but not parse-number.([here are two](
http://www.reddit.com/r/lisp/comments/c ... ns/c0swsih), mine doesn't do fractions atm, btw) Similarly, it doesn't seem to have a parse-symbol/parse-word. Easy to make though.
- Code: Select all
(defun parse-word (stream)
(with-output-to-string (out)
(flet ((rch ()
(read-char stream nil :eof)))
(do ((ch (rch) (rch)))
((case ch ((:eof #\Space #\Newline #\Tab) t)) nil)
(write-char ch out)))))