This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: building lists with gh_load()
- To: Alexander Langer <alex at big dot endian dot de>
- Subject: Re: building lists with gh_load()
- From: Dirk Herrmann <dirk at ida dot ing dot tu-bs dot de>
- Date: Tue, 21 Dec 1999 12:01:58 +0100 (MET)
- cc: guile at sourceware dot cygnus dot com
On Wed, 15 Dec 1999, Alexander Langer wrote:
> I Probably just don't know how to let a _file_ return a value in
> libguile, so that the returned value of the file will be the value
> of gh_load();
>
> Can someone give me a hint?-)
Sorry for the late answer, but I was disconnected from the net for 10 days
now.
The solution to your problem is to use a special routine:
(define (load/value fname)
(with-input-from-file fname
(lambda ()
(let loop ((sexpr (read))
(result #f))
(if (eof-object? sexpr)
result
(loop (read) (eval sexpr)))))))
Maybe it needs some improvement for the use with modules, but itīs a
start. By the way, itīs not my code. A very long time ago I had the same
question asked on a newsgroup and got this as an answer. Shame on me that
I did not note the original author to give credit to him.
Good luck,
Dirk Herrmann