guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

The return value of `load'


From: Panicz Maciej Godek
Subject: The return value of `load'
Date: Mon, 1 Aug 2011 15:02:58 +0200

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]