David Kastrup <d...@gnu.org> writes:

> How will either fare with:
>
> (let ((env
>   (let ((x 1))
>     (the-environment))))
>   (local-eval '(set! x 4) env))

This example (or more complex ones based on the same idea) present no
difficulties for either patch.

  scheme@(guile-user)> (use-modules (ice-9 local-eval))
  scheme@(guile-user)> (let ((env (let ((x 1))
                                    (the-environment))))
                         (local-eval '(set! x 4) env)
                         env)
  $1 = #<lexical-environment (guile-user) ((x 4)) ()>

They work even if you replace the outer `let' with `letrec', so that
(the-environment) captures its own binding (though attempts to print
such an environment cause an infinite recursion :)

  scheme@(guile-user)> (letrec ((env (let ((x 1))
                                    (the-environment))))
                         (local-eval '(set! x 4) env)
                         env)
  $3 = #<lexical-environment (guile-user) ice-9/format.scm:42:2: In procedure 
format:
  ice-9/format.scm:42:2: Throw to key `vm-error' with args `(vm-run "VM: Stack 
overflow" ())'.
  
  Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
  scheme@(guile-user) [1]> ,q
  scheme@(guile-user)> (local-eval 'x $3)
  $4 = 4
  scheme@(guile-user)> 

     Best,
      Mark

Reply via email to