read-from-string
read-from-string string &optional eof-error-p eof-value &key start end preserve-whitespace → object, position
string—a string.
eof-error-p—a generalized boolean. The default is true.
eof-value—an object. The default is nil.
start, end—bounding index designators of string. The defaults for start and end are 0 and nil, respectively.
preserve-whitespace—a generalized boolean. The default is false.
object—an object (parsed by the Lisp reader) or the eof-value.
position—an integer greater than or equal to zero, and less than or equal to one more than the length of the string.
22.2.1 40Parses the printed representation of an object from the subsequence of string bounded by start and end, as if read had been called on an input stream containing those same characters.
This seems unnecessary/redundant to me. 22.2.1 39 The characters of \param{string} are given successively to the \term{Lisp reader}, and the \term{object} is built by the reader.
22.2.1 41If preserve-whitespace is true, the operation will preserve whitespace2 as read-preserving-whitespace would do.
22.2.1 43If an object is successfully parsed, the primary value, object, is the object that was parsed. If eof-error-p is false and if the end of the substring is reached, eof-value is returned.
The secondary value, position, is the index of the first character in the bounded string that was not read. The position may depend upon the value of preserve-whitespace. Amazing. CLtL really says this. I wonder why. -kmp 23-Jan-92If the entire string was read, the position returned is either the length of the string or one greater than the length of the string.
22.2.1 44
(read-from-string " 1 3 5" t nil :start 2) → 3, 5 (read-from-string "(a b c)") → (A B C), 7
None.
None.
22.2.1 42If the end of the supplied substring occurs before an object can be read, an error is signaled if eof-error-p is true. An error is signaled if the end of the substring occurs in the middle of an incomplete object.
read, read-preserving-whitespace
Moon and Sandra seemed to believe this was the motivation. I felt we should record the fact. -kmp 24-Jan-92The reason that position is allowed to be beyond the length of the string is to permit (but not require) the implementation to work by simulating the effect of a trailing delimiter at the end of the bounded string. When preserve-whitespace is true, the position might count the simulated delimiter.