Lisp HUG Maillist Archive

read-from-string and errors

Hello all,

I'm reading the doc for read-from-string, and I see the following:


"Description:
....
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. "


However, I'm getting:

CL-USER 11 > (read-from-string "(car" nil :EOF)

Error: End of file while reading stream #<System::String-Input-Stream 104408B7>.
  1 (abort) Return to level 0.
  2 Return to top loop level 0.

Type :b for backtrace, :c <option number> to proceed,  or :? for other options

CL-USER 12 : 1 >

and I think that I'm unclear on when read-from-string is suppoed to
signal an error. It would seem
to me that no object was sucessfully parsed, that  eof-error-p is
false, and that the end of the
substring was reached, and as such I should get the eof-value, :EOF.
If this isn't correct, then
in what cases would end of string be reached and the eof-value
returned without some other
error coming first? ( know of one case, the empty string, e.g.,
(read-from-string "" nil :EOF)).

Thanks!
-- 
=====================
Joshua Taylor
tayloj@rpi.edu


Re: read-from-string and errors

On Wed, 26 Jul 2006 14:12:56 -0400, "Taylor, Joshua" <tayloj@rpi.edu> wrote:

> I'm reading the doc for read-from-string, and I see the following:
>
> "Description:
> ...
> 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. "
>
> However, I'm getting:
>
> CL-USER 11 > (read-from-string "(car" nil :EOF)
>
> Error: End of file while reading stream #<System::String-Input-Stream 104408B7>.
>   1 (abort) Return to level 0.
>   2 Return to top loop level 0.
>
> Type :b for backtrace, :c <option number> to proceed,  or :? for other options
>
> CL-USER 12 : 1 >
>
> and I think that I'm unclear on when read-from-string is suppoed to
> signal an error. It would seem to me that no object was sucessfully
> parsed, that eof-error-p is false, and that the end of the substring
> was reached, and as such I should get the eof-value, :EOF.  If this
> isn't correct, then in what cases would end of string be reached and
> the eof-value returned without some other error coming first? ( know
> of one case, the empty string, e.g., (read-from-string "" nil
> :EOF)).

Under "Exceptional Situations" it says:

  "An error is signaled if the end of the substring occurs in the
   middle of an incomplete object."

I think that is what you're seeing.

Cheers,
Edi.


Re: read-from-string and errors

That would explain it. I guess I thought I encountered an end of file
before I finished
reading the documentation. -_-;

On 7/26/06, Edi Weitz <edi@agharta.de> wrote:
> On Wed, 26 Jul 2006 14:12:56 -0400, "Taylor, Joshua" <tayloj@rpi.edu> wrote:
>
> > I'm reading the doc for read-from-string, and I see the following:
> >
> > "Description:
> > ...
> > 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. "
> >
> > However, I'm getting:
> >
> > CL-USER 11 > (read-from-string "(car" nil :EOF)
> >
> > Error: End of file while reading stream #<System::String-Input-Stream 104408B7>.
> >   1 (abort) Return to level 0.
> >   2 Return to top loop level 0.
> >
> > Type :b for backtrace, :c <option number> to proceed,  or :? for other options
> >
> > CL-USER 12 : 1 >
> >
> > and I think that I'm unclear on when read-from-string is suppoed to
> > signal an error. It would seem to me that no object was sucessfully
> > parsed, that eof-error-p is false, and that the end of the substring
> > was reached, and as such I should get the eof-value, :EOF.  If this
> > isn't correct, then in what cases would end of string be reached and
> > the eof-value returned without some other error coming first? ( know
> > of one case, the empty string, e.g., (read-from-string "" nil
> > :EOF)).
>
> Under "Exceptional Situations" it says:
>
>   "An error is signaled if the end of the substring occurs in the
>    middle of an incomplete object."
>
> I think that is what you're seeing.
>
> Cheers,
> Edi.
>


-- 
=====================
Joshua Taylor
tayloj@rpi.edu


Updated at: 2020-12-10 08:48 UTC