This is the mail archive of the guile@sourceware.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: building lists with gh_load()


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


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