User Tools


Function READ-FROM-STRING

Syntax

  • read-from-string string &optional eof-error-p eof-value &key start end preserve-whitespaceobject, position

Arguments and Values

Description

Parses 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.

If preserve-whitespace is true, the operation will preserve whitespace as read-preserving-whitespace would do.

If 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.

If the entire string was read, the position returned is either the length of the string or one greater than the length of the string.

Examples

(read-from-string " 1 3 5" t nil :start 2)

3 5

(read-from-string "(a b c)")

(A B C) 7

Side Effects

None.

Affected By

None.

Exceptional Situations

If 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.

See Also

Notes

The 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.

\issue{ARGUMENTS-UNDERSPECIFIED:SPECIFY} \issue{SUBSEQ-OUT-OF-BOUNDS} \issue{RANGE-OF-START-AND-END-PARAMETERS:INTEGER-AND-INTEGER-NIL}