[plt-scheme] string-eval

From: djneu at att.net (djneu at att.net)
Date: Wed Mar 23 18:58:14 EST 2005

Robby, Jens,

Many thanks - using ~s did it!

Any thoughts for the Scheme Cookbook folks on whether it's worth
putting a note in one of the recipes Jens referenced or maybe
creating a new one?

Cheers,
David

 -------------- Original message ----------------------
From: Robby Findler <robby at cs.uchicago.edu>
> You need to use
> 
>   ~s
> 
> not ~a.
> 
> If you look closely at the first case, you'll see that you're getting
> back a symbol, not a string. ~s means to use `write' and ~a means to
> use display.
> 
> Robby
> 
> At Wed, 23 Mar 2005 17:50:24 -0500, "David J. Neu" wrote:
> >   For list-related administrative tasks:
> >   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> > 
> > Hi,
> > 
> > I'd like to be able to store an association list in a DBMS and later
> > retrieve it.
> > 
> > The code below works fine for
> > (define alist `((a . 1) (b . "foo")))
> > 
> > but generates the error:
> > 
> > UNKNOWN::26: read: unexpected ')'
> > 
> > when b is "", i.e. for
> > (define alist `((a . 1) (b . "")))
> > 
> > Many thanks for any suggestions!
> > 
> > Cheers,
> > David
> > 
> > 
> > 
> > (require (lib "string.ss")
> > 	 (lib "pconvert.ss"))
> > 
> > (define alist `((a . 1) (b . "")))
> > 
> > ;; simulate storing alist in a DBMS and reading it back
> > (define alist-as-string (format "~a" (print-convert alist)))
> > 
> > (eval-string alist-as-string)
> > 
> > UNKNOWN::26: read: unexpected ')'




Posted on the users mailing list.