guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] GNU Guile branch, master, updated. release_1-9-3-78-g1eb


From: Ludovic Courtès
Subject: [Guile-commits] GNU Guile branch, master, updated. release_1-9-3-78-g1ebe6a6
Date: Thu, 15 Oct 2009 19:31:06 +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=1ebe6a63686b341b55848b0dc0532e7b0d665c15

The branch, master has been updated
       via  1ebe6a63686b341b55848b0dc0532e7b0d665c15 (commit)
       via  30e73c7698daa038a3fce2135781166d1edfa4e0 (commit)
      from  3245c0fbefa2f119918e42cc1691fb9a41feb792 (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 1ebe6a63686b341b55848b0dc0532e7b0d665c15
Author: Ludovic Courtès <address@hidden>
Date:   Thu Oct 15 21:29:42 2009 +0200

    Document the interaction of the "compilee" with the compiler's current 
module.
    
    This is a followup to 87c595c757b7db84ffdcfda96f736ab235e674a8 ("Compile
    in a fresh module by default.") and
    f65e2b1ec5ae1962e57322ac3085ab4d44025694 ("Honor and confine
    expansion-time side-effects to `current-reader'.").
    
    * doc/ref/api-evaluation.texi (Loading): Explain how to change
      `current-reader' in a compiler-friendly way.
    
    * doc/ref/compiler.texi (The Scheme Compiler): Explain use of a fresh
      compilation module and separate `current-reader' fluid.
    
    * test-suite/tests/compiler.test ("current-reader")["with eval-when"]:
      New test.

commit 30e73c7698daa038a3fce2135781166d1edfa4e0
Author: Ludovic Courtès <address@hidden>
Date:   Thu Oct 15 20:51:16 2009 +0200

    Fix REPL environment for languages other than scheme.
    
    * module/system/repl/common.scm (repl-compile): Use `#:env #f' for
      languages other than scheme.

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

Summary of changes:
 doc/ref/api-evaluation.texi    |   15 +++++++++++++++
 doc/ref/compiler.texi          |   37 +++++++++++++++++++++++++++++++++++++
 module/system/repl/common.scm  |   12 +++++++++---
 test-suite/tests/compiler.test |    8 +++++++-
 4 files changed, 68 insertions(+), 4 deletions(-)

diff --git a/doc/ref/api-evaluation.texi b/doc/ref/api-evaluation.texi
index c484952..8abd9f9 100644
--- a/doc/ref/api-evaluation.texi
+++ b/doc/ref/api-evaluation.texi
@@ -572,6 +572,21 @@ that they are loading).  @code{current-reader} is a fluid, 
so it has an
 independent value in each dynamic root and should be read and set using
 @code{fluid-ref} and @code{fluid-set!} (@pxref{Fluids and Dynamic
 States}).
+
+Changing @code{current-reader} is typically useful to introduce local
+syntactic changes, such that code following the @code{fluid-set!} call
+is read using the newly installed reader.  The @code{current-reader}
+change should take place at evaluation time when the code is evaluated,
+or at compilation time when the code is compiled:
+
address@hidden eval-when
address@hidden
+(eval-when (compile eval)
+  (fluid-set! current-reader my-own-reader))
address@hidden example
+
+The @code{eval-when} form above ensures that the @code{current-reader}
+change occurs at the right time.
 @end defvar
 
 @defvar %load-hook
diff --git a/doc/ref/compiler.texi b/doc/ref/compiler.texi
index d749fc1..67a8ab4 100644
--- a/doc/ref/compiler.texi
+++ b/doc/ref/compiler.texi
@@ -236,12 +236,49 @@ which puts the user in the @code{(foo)} module. That is 
purpose of the
 when compiling the subsequent expression.
 
 For Scheme, an environment may be one of two things:
+
 @itemize
 @item @code{#f}, in which case compilation is performed in the context
 of the current module; or
 @item a module, which specifies the context of the compilation.
 @end itemize
 
+By default, the @code{compile} and @code{compile-file} procedures
+compile in a fresh module, such that bindings and macros introduced by
+the expression being compiled are isolated:
+
address@hidden
+(eq? (current-module) (compile '(current-module)))
address@hidden #f
+
+(compile '(define hello 'world))
+(defined? 'hello)
address@hidden #f
+
+(define / *)
+(eq? (compile '/) /)
address@hidden #f
address@hidden example
+
+Similarly, changes to the @code{current-reader} fluid (@pxref{Loading,
address@hidden) are isolated:
+
address@hidden
+(compile '(fluid-set! current-reader (lambda args 'fail)))
+(fluid-ref current-reader)
address@hidden #f
address@hidden example
+
+Nevertheless, having the compiler and @dfn{compilee} share the same name
+space can be achieved by explicitly passing @code{(current-module)} as
+the compilation environment:
+
address@hidden
+(define hello 'world)
+(compile 'hello #:env (current-module))
address@hidden world
address@hidden example
+
 @node Tree-IL
 @subsection Tree-IL
 
diff --git a/module/system/repl/common.scm b/module/system/repl/common.scm
index c9106e1..eac9610 100644
--- a/module/system/repl/common.scm
+++ b/module/system/repl/common.scm
@@ -67,9 +67,15 @@
   (let ((to (lookup-language (cond ((memq #:e opts) 'scheme)
                                    ((memq #:t opts) 'ghil)
                                    ((memq #:c opts) 'glil)
-                                   (else 'objcode)))))
-    (compile form #:from (repl-language repl) #:to to #:opts opts
-                  #:env (current-module))))
+                                   (else 'objcode))))
+        (from (repl-language repl)))
+    (compile form #:from from #:to to #:opts opts
+                  ;; XXX: Languages other than Scheme may not support having
+                  ;; a module as the environment, so work around that.  See
+                  ;; also `language-default-environment'.
+                  #:env (if (eq? from (lookup-language 'scheme))
+                            (current-module)
+                            #f))))
 
 (define (repl-parse repl form)
   (let ((parser (language-parser (repl-language repl))))
diff --git a/test-suite/tests/compiler.test b/test-suite/tests/compiler.test
index ed6f033..6d433eb 100644
--- a/test-suite/tests/compiler.test
+++ b/test-suite/tests/compiler.test
@@ -98,4 +98,10 @@
                    this-should-be-ignored")))
       (and (eq? (vm-load (the-vm) (read-and-compile input))
                 'ok)
-           (eq? r (fluid-ref current-reader))))))
+           (eq? r (fluid-ref current-reader)))))
+
+  (pass-if "with eval-when"
+    (let ((r (fluid-ref current-reader)))
+      (compile '(eval-when (compile eval)
+                  (fluid-set! current-reader (lambda args 'chbouib))))
+      (eq? (fluid-ref current-reader) r))))


hooks/post-receive
-- 
GNU Guile




reply via email to

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