Merge commit 'f6ddf827f8f192af7a8cd255bd8374a0d38bbb74'
authorAndy Wingo <wingo@pobox.com>
Fri, 7 Feb 2014 13:51:42 +0000 (14:51 +0100)
committerAndy Wingo <wingo@pobox.com>
Fri, 7 Feb 2014 13:51:42 +0000 (14:51 +0100)
Conflicts:
module/ice-9/boot-9.scm
module/oop/goops.scm

12 files changed:
doc/ref/api-macros.texi
module/ice-9/boot-9.scm
module/ice-9/i18n.scm
module/ice-9/poll.scm
module/ice-9/popen.scm
module/ice-9/r6rs-libraries.scm
module/oop/goops.scm
module/oop/goops/compile.scm
module/oop/goops/dispatch.scm
module/srfi/srfi-88.scm
module/system/foreign.scm
module/texinfo/serialize.scm

index 39c0f24..9964e6b 100644 (file)
@@ -1194,17 +1194,42 @@ The fix is to use @code{eval-when}.
 @example
 ;; correct: using eval-when
 (use-modules (srfi srfi-19))
-(eval-when (compile load eval)
+(eval-when (expand load eval)
   (define (date) (date->string (current-date))))
 (define-syntax %date (identifier-syntax (date)))
 (define *compilation-date* %date)
 @end example
 
 @deffn {Syntax} eval-when conditions exp...
-Evaluate @var{exp...} under the given @var{conditions}. Valid conditions include
-@code{eval}, @code{load}, and @code{compile}. If you need to use
-@code{eval-when}, use it with all three conditions, as in the above example.
-Other uses of @code{eval-when} may void your warranty or poison your cat.
+Evaluate @var{exp...} under the given @var{conditions}.  Valid
+conditions include:
+
+@table @code
+@item expand
+Evaluate during macro expansion, whether compiling or not.
+
+@item load
+Evaluate during the evaluation phase of compiled code, e.g. when loading
+a compiled module or running compiled code at the REPL.
+
+@item eval
+Evaluate during the evaluation phase of non-compiled code.
+
+@item compile
+Evaluate during macro expansion, but only when compiling.
+@end table
+
+In other words, when using the primitive evaluator, @code{eval-when}
+expressions with @code{expand} are run during macro expansion, and those
+with @code{eval} are run during the evaluation phase.
+
+When using the compiler, @code{eval-when} expressions with either
+@code{expand} or @code{compile} are run during macro expansion, and
+those with @code{load} are run during the evaluation phase.
+
+When in doubt, use the three conditions @code{(expand load eval)}, as in
+the example above.  Other uses of @code{eval-when} may void your
+warranty or poison your cat.
 @end deffn
 
 @node Macro Expansion
index 91728a6..bfcce0a 100644 (file)
@@ -2030,7 +2030,7 @@ written into the port is returned."
 
 (define-syntax-rule (add-to-load-path elt)
   "Add ELT to Guile's load path, at compile-time and at run-time."
-  (eval-when (compile load eval)
+  (eval-when (expand load eval)
     (set! %load-path (cons elt %load-path))))
 
 (define %load-verbosely #f)
@@ -3420,7 +3420,7 @@ but it fails to load."
            (interface options)
            (interface)))
        (define-syntax-rule (option-set! opt val)
-         (eval-when (eval load compile expand)
+         (eval-when (expand load eval)
            (options (append (options) (list 'opt val)))))))))
 
 (define-option-interface
@@ -3586,7 +3586,7 @@ but it fails to load."
 ;; Return a list of expressions that evaluate to the appropriate
 ;; arguments for resolve-interface according to SPEC.
 
-(eval-when (compile)
+(eval-when (expand)
   (if (memq 'prefix (read-options))
       (error "boot-9 must be compiled with #:kw, not :kw")))
 
@@ -3691,7 +3691,7 @@ but it fails to load."
                      (filename (let ((f (assq-ref (or (syntax-source x) '())
                                                   'filename)))
                                  (and (string? f) f))))
-         #'(eval-when (eval load compile expand)
+         #'(eval-when (expand load eval)
              (let ((m (define-module* '(name name* ...)
                         #:filename filename quoted-arg ...)))
                (set-current-module m)
@@ -3751,7 +3751,7 @@ but it fails to load."
     (syntax-case x ()
       ((_ spec ...)
        (with-syntax (((quoted-args ...) (quotify #'(spec ...))))
-         #'(eval-when (eval load compile expand)
+         #'(eval-when (expand load eval)
              (process-use-modules (list quoted-args ...))
              *unspecified*))))))
 
@@ -3838,19 +3838,19 @@ but it fails to load."
               names)))
 
 (define-syntax-rule (export name ...)
-  (eval-when (eval load compile expand)
+  (eval-when (expand load eval)
     (call-with-deferred-observers
      (lambda ()
        (module-export! (current-module) '(name ...))))))
 
 (define-syntax-rule (re-export name ...)
-  (eval-when (eval load compile expand)
+  (eval-when (expand load eval)
     (call-with-deferred-observers
      (lambda ()
        (module-re-export! (current-module) '(name ...))))))
 
 (define-syntax-rule (export! name ...)
-  (eval-when (eval load compile expand)
+  (eval-when (expand load eval)
     (call-with-deferred-observers
      (lambda ()
        (module-replace! (current-module) '(name ...))))))
index ca949b4..1d12dd0 100644 (file)
@@ -83,7 +83,7 @@
            locale-yes-regexp locale-no-regexp))
 
 
-(eval-when (eval load compile)
+(eval-when (expand load eval)
   (load-extension (string-append "libguile-" (effective-version))
                   "scm_init_i18n"))
 
index 1633dcb..57b5047 100644 (file)
@@ -34,7 +34,7 @@
             poll-set-remove!
             poll))
 
-(eval-when (eval load compile)
+(eval-when (expand load eval)
   (load-extension (string-append "libguile-" (effective-version))
                   "scm_init_poll"))
 
index 48a52e6..b166e9d 100644 (file)
@@ -24,7 +24,7 @@
   :export (port/pid-table open-pipe* open-pipe close-pipe open-input-pipe
           open-output-pipe open-input-output-pipe))
 
-(eval-when (load eval compile)
+(eval-when (expand load eval)
   (load-extension (string-append "libguile-" (effective-version))
                   "scm_init_popen"))
 
index 428d951..a68df3c 100644 (file)
     (syntax-case stx ()
       ((_ import-set ...)
        (with-syntax (((library-reference ...) (map strip-for #'(import-set ...))))
-         #'(eval-when (eval load compile expand)
+         #'(eval-when (expand load eval)
              (let ((iface (resolve-r6rs-interface 'library-reference)))
                (call-with-deferred-observers
                  (lambda ()
index 1b86399..a64e03b 100644 (file)
@@ -1,6 +1,6 @@
 ;;; installed-scm-file
 
-;;;; Copyright (C) 1998,1999,2000,2001,2002, 2003, 2006, 2009, 2010, 2011, 2013 Free Software Foundation, Inc.
+;;;; Copyright (C) 1998,1999,2000,2001,2002, 2003, 2006, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc.
 ;;;; Copyright (C) 1993-1998 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
 ;;;;
 ;;;; This library is free software; you can redistribute it and/or
 (define *goops-module* (current-module))
 
 ;; First initialize the builtin part of GOOPS
-(eval-when (eval load compile)
+(eval-when (expand load eval)
   (%init-goops-builtins))
 
-(eval-when (eval load compile)
+(eval-when (expand load eval)
   (use-modules ((language tree-il primitives) :select (add-interesting-primitive!)))
   (add-interesting-primitive! 'class-of))
 
 
 \f
 ;; FIXME: deprecate.
-(eval-when (eval load compile)
+(eval-when (expand load eval)
   (define min-fixnum (- (expt 2 29)))
   (define max-fixnum (- (expt 2 29) 1)))
 
index ace89b4..8c546e0 100644 (file)
@@ -19,7 +19,7 @@
 ;; There are circularities here; you can't import (oop goops compile)
 ;; before (oop goops). So when compiling, make sure that things are
 ;; kosher.
-(eval-when (compile) (resolve-module '(oop goops)))
+(eval-when (expand) (resolve-module '(oop goops)))
 
 (define-module (oop goops compile)
   :use-module (oop goops)
index 76f16fb..0198a9f 100644 (file)
@@ -19,7 +19,7 @@
 ;; There are circularities here; you can't import (oop goops compile)
 ;; before (oop goops). So when compiling, make sure that things are
 ;; kosher.
-(eval-when (compile) (resolve-module '(oop goops)))
+(eval-when (expand) (resolve-module '(oop goops)))
 
 (define-module (oop goops dispatch)
   #:use-module (oop goops)
index b9056a4..043a4a7 100644 (file)
@@ -35,7 +35,7 @@
 \f
 ;; Change the keyword syntax both at compile time and run time; the latter is
 ;; useful at the REPL.
-(eval-when (compile load)
+(eval-when (expand load eval)
   (read-set! keywords 'postfix))
 
 (define (keyword->string k)
index 01a71b8..3304eb0 100644 (file)
@@ -55,7 +55,7 @@
 
             define-wrapped-pointer-type))
 
-(eval-when (load eval compile)
+(eval-when (expand load eval)
   (load-extension (string-append "libguile-" (effective-version))
                   "scm_init_foreign"))
 
index d0c6f50..f3840c4 100644 (file)
@@ -60,7 +60,7 @@
 
 ;; Why? Well, because syntax-case defines `include', and carps about its
 ;; wrong usage below...
-(eval-when (eval load compile)
+(eval-when (expand load eval)
   (define (include exp lp command type formals args accum)
     (list* "\n"
            (list-intersperse