Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!news.mathworks.com!newsfeed.internetmci.com!in2.uu.net!news1.digital.com!decwrl!amd!netcomsv!uu4news.netcom.com!netcomsv!uu3news.netcom.com!ix.netcom.com!netcom.com!vrotney
From: vrotney@netcom.com (William Paul Vrotney)
Subject: Re: read-from-string
In-Reply-To: lavelli@irst.it's message of 26 Mar 1996 14:44:22 GMT
Message-ID: <vrotneyDowKGn.329@netcom.com>
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
References: <4j8vs6$7ui@wonder.itc.it>
Date: Wed, 27 Mar 1996 01:36:22 GMT
Lines: 33
Sender: vrotney@netcom.netcom.com

In article <4j8vs6$7ui@wonder.itc.it> lavelli@irst.it (Alberto Lavelli) writes:

>    I'd need a function that tells me if a string contains a s-expr or not.  
>    My first thought was that of using 'read-from-string' with the eof-error-p
>    parameter set to nil; i.e.
> 
> 
>    (read-from-string "(A S" nil 'error)
> 
> 
>    But Allegro complains and I get an error saying that the reader has
>    encountered eof on the stream. I read the manual and my understanding is
>    this should not be the correct behaviour. Am I missing something 
>    fundamental?

I noticed that in the latest Allegro CL man page for READ-FROM-STRING it
says

    The function read-from-string always signals an error
    if the end of string is reached when a COMMON LISP object  is  partially
    but not completely read.

I know it's yuckie but you can probably solve your problem with

    (multiple-value-bind (value condition)
     (ignore-errors
      (read-from-string "(A S"))
     (if (typep condition 'condition) 'error value))


-- 

William P. Vrotney - vrotney@netcom.com
