[plt-scheme] read-sexp?

From: Richard Cleis (rcleis at mac.com)
Date: Tue May 3 22:27:19 EDT 2005

Do you need to use read-line?  (read) replies with objects that can be 
(eval)'d even if there is no separation between s-expressions.

(define ois (open-input-string "(+ 3 4)(func 3 7)(incompl"))
(define exp1 (read ois))
(define exp2 (read ois))

An exception handler is needed to read the third one.

(eval exp1) replies with 7
(eval exp2) needs func defined

DrScheme conveniently displays the objects at the prompt:

 > exp2
(func 3 7)

I missed the flat-file discussion; maybe I am missing your point, too.  
But this stuff is still fun to me!


On May 3, 2005, at 6:57 PM, Mike wrote:

>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> Previously I was building libraries (and still am).
> Now I have a need to replace a perl program. I want to
> write this in scheme. There was a recent discussion on
> using (write) and (read) for processing flat-files.
> I have tested the (read-line), but can't guarentee(?)
> what is written to the file will have sexps on a single
> line.
> I've thought about implementing a custom reader to
> read the sexps. Has anyone done this? Is there some
> code I can follow/learn from?
> Thanks.
> Mike

Posted on the users mailing list.