unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* The return value of `load'
@ 2011-08-01 13:02 Panicz Maciej Godek
  2012-01-09 15:16 ` Andy Wingo
  0 siblings, 1 reply; 2+ messages in thread
From: Panicz Maciej Godek @ 2011-08-01 13:02 UTC (permalink / raw)
  To: guile-user

Hey,
let's assume that I have two files. The first one contains a single sexp:
2plus3.scm:
(+ 2 3)

Now I would like to load that file, just like the `load' or `primitive-load'
does, but I would like to have an access to the return value of the last
expression from the file:

(define x (load "2plus3.scm")) ; (i wish x was 5)

The similar effect could be achieved using

(let* ((f (open-file "2plus3.scm" "r"))
       (v (read f)))
  (close f)
  (primitive-eval v))

but I was wondering if it was possible to implement this feature
as a default behavior of `load' or `primitive-load' -- it would be convenient
for the programs that would want to store the data in the external files.

Regards
M.



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: The return value of `load'
  2011-08-01 13:02 The return value of `load' Panicz Maciej Godek
@ 2012-01-09 15:16 ` Andy Wingo
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Wingo @ 2012-01-09 15:16 UTC (permalink / raw)
  To: Panicz Maciej Godek; +Cc: guile-user

On Mon 01 Aug 2011 15:02, Panicz Maciej Godek <godek.maciek@gmail.com> writes:

> (define x (load "2plus3.scm")) ; (i wish x was 5)

I have fixed this to return the result(s) of evaluating the last
expression in the file, or the unspecified value if the file has no
forms.  Previously there was differing behavior: primitive-load didn't
return the values, but load-compiled (which `load' could call) would
return the values.

Andy
-- 
http://wingolog.org/



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-01-09 15:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-01 13:02 The return value of `load' Panicz Maciej Godek
2012-01-09 15:16 ` Andy Wingo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).