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: Changing environments


thi <ttn@mingle.glug.org> writes:

> probably the easiest thing to do is to start another repl on top of the
> current one.  if you never want to return to the current one, just use
> `(begin (new-repl) (quit))' -- assuming you don't recurse further. :->

I've changed eval so that it now accepts an environment:

(eval sourc (next-repl-environment))

which evaluates sourc in the environment "next-repl-environment".
(ge <environment>) changes next-repl-environment as a side effect
and when the next repl loop starts, sourc will be evaluated in
the new environment.

Ugly but it works. :)


guile> (ge (make-finite-environment)) ; go to empty environment
guile> (define a 9)
guile> (eval '(display a) (let ((a (+ a 1))) (the-environment)))
10guile> (eval '(display a) (make-finite-environment))
ERROR: Unbound variable: a
ABORT: (misc-error)


Jost