guile-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] Implement local-eval, local-compile, and the-environment


From: Mark H Weaver
Subject: Re: [PATCH] Implement local-eval, local-compile, and the-environment
Date: Tue, 03 Jan 2012 13:45:49 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

David Kastrup <address@hidden> 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

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