guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.3-196-g0133e


From: Andy Wingo
Subject: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.3-196-g0133e13
Date: Thu, 26 Jan 2012 17:21:09 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=0133e13f3424db582f3f58c13d6f3dc0627bd53b

The branch, stable-2.0 has been updated
       via  0133e13f3424db582f3f58c13d6f3dc0627bd53b (commit)
       via  68c31a42ab137a5a54a577f19a69dfcbcfd33271 (commit)
      from  6dc8c138f902abeeabde23dc6fb29bd11e29da3b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0133e13f3424db582f3f58c13d6f3dc0627bd53b
Author: Andy Wingo <address@hidden>
Date:   Thu Jan 26 18:21:01 2012 +0100

    fix test-loose-ends
    
    * test-suite/standalone/test-loose-ends.c (test_scm_local_eval): Use
      ice-9 local-eval to get (the-environment).

commit 68c31a42ab137a5a54a577f19a69dfcbcfd33271
Author: Andy Wingo <address@hidden>
Date:   Thu Jan 26 16:22:35 2012 +0100

    update local-eval docs
    
    * doc/ref/api-evaluation.texi (Local Evaluation): Update docs, add some
      examples.

-----------------------------------------------------------------------

Summary of changes:
 doc/ref/api-evaluation.texi             |   67 +++++++++++++++++++++----------
 test-suite/standalone/test-loose-ends.c |    5 ++-
 2 files changed, 50 insertions(+), 22 deletions(-)

diff --git a/doc/ref/api-evaluation.texi b/doc/ref/api-evaluation.texi
index cc62270..f2b539e 100644
--- a/doc/ref/api-evaluation.texi
+++ b/doc/ref/api-evaluation.texi
@@ -984,6 +984,14 @@ value.
 @node Local Evaluation
 @subsection Local Evaluation
 
+Guile includes a facility to capture a lexical environment, and later
+evaluate a new expression within that environment.  This code is
+implemented in a module.
+
address@hidden
+(use-modules (ice-9 local-eval))
address@hidden example
+
 @deffn syntax the-environment
 Captures and returns a lexical environment for use with
 @code{local-eval} or @code{local-compile}.
@@ -991,27 +999,44 @@ Captures and returns a lexical environment for use with
 
 @deffn {Scheme Procedure} local-eval exp env
 @deffnx {C Function} scm_local_eval (exp, env)
-Evaluate the expression @var{exp} in the lexical environment @var{env}.
-This mostly behaves as if @var{exp} had been wrapped in a lambda
-expression @code{`(lambda () ,@var{exp})} and put in place of
address@hidden(the-environment)}, with the resulting procedure called by
address@hidden  In other words, @var{exp} is evaluated within the
-lexical environment of @code{(the-environment)}, but within the dynamic
-environment of the call to @code{local-eval}.
address@hidden deffn
-
address@hidden {Scheme Procedure} local-compile exp env [opts=()]
-Compile the expression @var{exp} in the lexical environment @var{env}.
-If @var{exp} is a procedure, the result will be a compiled procedure;
-otherwise @code{local-compile} is mostly equivalent to
address@hidden  @var{opts} specifies the compilation options.
address@hidden deffn
-
-Note that the current implementation of @code{(the-environment)} does
-not capture local syntax transformers bound by @code{let-syntax},
address@hidden or non-top-level @code{define-syntax} forms.  Any
-attempt to reference such captured syntactic keywords via
address@hidden or @code{local-compile} produces an error.
address@hidden {Scheme Procedure} local-compile exp env [opts=()]
+Evaluate or compile the expression @var{exp} in the lexical environment
address@hidden
address@hidden deffn
+
+Here is a simple example, illustrating that it is the variable
+that gets captured, not just its value at one point in time.
+
address@hidden
+(define e (let ((x 100)) (the-environment)))
+(define fetch-x (local-eval '(lambda () x) e))
+(fetch-x)
address@hidden 100
+(local-eval '(set! x 42) e)
+(fetch-x)
address@hidden 42
address@hidden example
+
+While @var{exp} is evaluated within the lexical environment of
address@hidden(the-environment)}, it has the dynamic environment of the call to
address@hidden
+
address@hidden and @code{local-compile} can only evaluate
+expressions, not definitions.
+
address@hidden
+(local-eval '(define foo 42)
+            (let ((x 100)) (the-environment)))
address@hidden syntax error: definition in expression context
address@hidden example
+
+Note that the current implementation of @code{(the-environment)} only
+captures ``normal'' lexical bindings, and pattern variables bound by
address@hidden  It does not currently capture local syntax
+transformers bound by @code{let-syntax}, @code{letrec-syntax} or
+non-top-level @code{define-syntax} forms.  Any attempt to reference such
+captured syntactic keywords via @code{local-eval} or
address@hidden produces an error.
 
 
 @c Local Variables:
diff --git a/test-suite/standalone/test-loose-ends.c 
b/test-suite/standalone/test-loose-ends.c
index f815ae2..d1d6831 100644
--- a/test-suite/standalone/test-loose-ends.c
+++ b/test-suite/standalone/test-loose-ends.c
@@ -45,7 +45,10 @@ test_scm_from_locale_keywordn ()
 static void
 test_scm_local_eval ()
 {
-  SCM result = scm_local_eval
+  SCM result;
+
+  scm_c_use_module ("ice-9 local-eval");
+  result = scm_local_eval
     (scm_list_3 (scm_from_latin1_symbol ("+"),
                  scm_from_latin1_symbol ("x"),
                  scm_from_latin1_symbol ("y")),


hooks/post-receive
-- 
GNU Guile



reply via email to

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