Reputation: 3618
I am trying to make use of function read-from-string, however i cannot make heads from tails with it.
If i understand documentation correctly, if second parameter is not true, then unbalanced expression in supplied string should not cause an error. However, if in try it out, i get:
> (read-from-string "(1 2" t 'EOF)
Condition of type: END-OF-FILE Unexpected end of file on #<string-input stream from "(1 2">.
Available restarts:
- (RESTART-TOPLEVEL) Go back to Top-Level REPL.
Broken at SI:BYTECODES. [Evaluation of: (READ-FROM-STRING "(1 2" ...)] In: #<process TOP-LEVEL>.
>> 1
1
>> (read-from-string "(1 2" nil 'EOF)
Debugger received error of type: END-OF-FILE Unexpected end of file on #<string-input stream from "(1 2">. Error flushed.
No matter shat i send, i always get an error.
I am using ECL 15.3.7
Upvotes: 0
Views: 884
Reputation:
The eof-error-p
and eof-value
optional arguments control the result if you hit the end of the string before finding anything at all. So:
> (read-from-string "")
Error: ...
while
> (read-from-string "" nil 'foo)
foo
0
If the end of the string occurs part-way through an incomplete object an error is always signaled. The spec is clear on this although it's fairly far down the entry:
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.
Upvotes: 3