This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: The taming of gh_eval_str()


> 1) Passing garbage input to gh_eval_str() causes guile to spit out an
> error and *exit*, thus taking down my entire server. This is not desirable
> behavior. What is the proper way to trap/display such errors and avoid
> termination?

I had a quick go at a web server in guile (until someone caught me and made me
do real work) and I opted for the easier solution of writing a low level
server in C that just looks after the listner socket and all of the connection
sockets, passing information through a pipe to the guile process.
The low level server actually constructs scheme commands to send through the
pipe so the guile process can just run in a repl and interpret commands
as they come to it. When an error turns up it gets a print to stderr and
you can look at the TTY that the server is running on and try to puzzzle out
what is going wrong. The performance suffers from excess copying though :-(

> 2) Is there a nice (i.e., already coded by you wonderful people :))  way
> to get a string (char*) representation for an arbitrary SCM, or do I have
> to test to see what type of data it is and do the conversions myself? I'd
> hate to duplicate effort. 

If you have to write some code, write a `string-port' for guile. This would
be an object that functions just like any other port but reads and writes
to a string buffer. Once you have that, you can do all of your conversions
through (read), (display) and (write). With respect to a WWW server, I found
that there was no easy way to allow remote (eval) of guile code -- even when
I had the necessary code in a string I still had to (display) it to a file and
(load) the file back in, yuk!

	- Tel