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.7-46-g5745de


From: Andy Wingo
Subject: [Guile-commits] GNU Guile branch, stable-2.0, updated. v2.0.7-46-g5745de9
Date: Tue, 22 Jan 2013 14:38:32 +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=5745de917272804ab2b33a3271940b913d0d7c70

The branch, stable-2.0 has been updated
       via  5745de917272804ab2b33a3271940b913d0d7c70 (commit)
       via  a6bd32406d952689494124de56b2d4de7cafac98 (commit)
      from  5a35d42aa5be26f1048fceea9acfa21bc9f6bc3e (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 5745de917272804ab2b33a3271940b913d0d7c70
Author: Andy Wingo <address@hidden>
Date:   Mon Jan 21 11:21:19 2013 +0100

    current-language is a parameter in boot-9
    
    * module/ice-9/boot-9.scm (current-language): New parameter.
    
    * module/system/base/language.scm (*current-language*): Pull fluid from
      parameter.
      (current-language): Now a re-exported parameter.
    
    * doc/ref/compiler.texi: Update reference from *current-language* fluid
      to current-language parameter.
    
    * module/system/base/compile.scm (compile-and-load):
    * module/ice-9/top-repl.scm (top-repl): Default to the current language,
      not to Scheme.
    
    * module/ice-9/eval-string.scm:
    * module/system/base/language.scm:
    * module/system/repl/command.scm:
    * module/system/repl/repl.scm: Update to use current-language parameter
      and parameterize.

commit a6bd32406d952689494124de56b2d4de7cafac98
Author: Andy Wingo <address@hidden>
Date:   Mon Jan 21 11:16:29 2013 +0100

    add fluid->parameter
    
    * module/ice-9/boot-9.scm (make-parameter): Add a docstring.
      (fluid->parameter): New interface.  Use it when turning port fluids
      into parameters.
    
    * doc/ref/api-scheduling.texi (Parameters): Deffn instead of defun for
      make-parameter documentation.  Add docs for fluid->parameter.

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

Summary of changes:
 doc/ref/api-scheduling.texi     |   21 +++++++++++--
 doc/ref/compiler.texi           |    9 +++--
 module/ice-9/boot-9.scm         |   65 +++++++++++++++++++++++++++++++++-----
 module/ice-9/eval-string.scm    |    4 +-
 module/ice-9/top-repl.scm       |    4 +-
 module/system/base/compile.scm  |    2 +-
 module/system/base/language.scm |   12 +++---
 module/system/repl/command.scm  |    4 +-
 module/system/repl/repl.scm     |    8 ++--
 9 files changed, 96 insertions(+), 33 deletions(-)

diff --git a/doc/ref/api-scheduling.texi b/doc/ref/api-scheduling.texi
index 9c2b413..749583a 100644
--- a/doc/ref/api-scheduling.texi
+++ b/doc/ref/api-scheduling.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2007, 
2009, 2010, 2012
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2007, 
2009, 2010, 2012, 2013
 @c   Free Software Foundation, Inc.
 @c See the file guile.texi for copying conditions.
 
@@ -869,7 +869,7 @@ through several layers of calls before reaching the point 
they should
 affect.  And introducing a new setting to existing code is often easier
 with a parameter object than adding arguments.
 
address@hidden make-parameter init [converter]
address@hidden {Scheme Procedure} make-parameter init [converter]
 Return a new parameter object, with initial value @var{init}.
 
 If a @var{converter} is given, then a call @code{(@var{converter}
@@ -888,7 +888,7 @@ canonical form.  For example,
 (my-param 0.75)
 (my-param) @result{} 3/4
 @end example
address@hidden defun
address@hidden deffn
 
 @deffn {library syntax} parameterize ((param value) @dots{}) body1 body2 
@dots{}
 Establish a new dynamic scope with the given @var{param}s bound to new
@@ -926,6 +926,21 @@ locations.  That includes the separate locations when 
outside any
 separate initial location in each dynamic state, all initialized to the
 given @var{init} value.
 
+New code should probably just use parameters instead of fluids, because
+the interface is better.  But for migrating old code or otherwise
+providing interoperability, Guile provides the @code{fluid->parameter}
+procedure:
+
address@hidden {Scheme Procedure} fluid->parameter fluid [conv]
+Make a parameter that wraps a fluid.
+
+The value of the parameter will be the same as the value of the fluid.
+If the parameter is rebound in some dynamic extent, perhaps via
address@hidden, the new value will be run through the optional
address@hidden procedure, as with any parameter.  Note that unlike
address@hidden, @var{conv} is not applied to the initial value.
address@hidden deffn
+
 As alluded to above, because each thread usually has a separate dynamic
 state, each thread has its own locations behind parameter objects, and
 changes in one thread are not visible to any other.  When a new dynamic
diff --git a/doc/ref/compiler.texi b/doc/ref/compiler.texi
index 25cf524..a88942d 100644
--- a/doc/ref/compiler.texi
+++ b/doc/ref/compiler.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C)  2008, 2009, 2010
address@hidden Copyright (C)  2008, 2009, 2010, 2013
 @c   Free Software Foundation, Inc.
 @c See the file guile.texi for copying conditions.
 
@@ -112,9 +112,10 @@ subsequent calls to @code{define-language}, so it should 
be quite
 fast.
 @end deffn
 
-There is a notion of a ``current language'', which is maintained in
-the @code{*current-language*} fluid. This language is normally Scheme,
-and may be rebound by the user. The run-time compilation interfaces
+There is a notion of a ``current language'', which is maintained in the
address@hidden parameter, defined in the core @code{(guile)}
+module. This language is normally Scheme, and may be rebound by the
+user. The run-time compilation interfaces
 (@pxref{Read/Load/Eval/Compile}) also allow you to choose other source
 and target languages.
 
diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 77bb84a..4efd753 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -2929,6 +2929,34 @@ but it fails to load."
 (set-struct-vtable-name! <parameter> '<parameter>)
 
 (define* (make-parameter init #:optional (conv (lambda (x) x)))
+  "Make a new parameter.
+
+A parameter is a dynamically bound value, accessed through a procedure.
+To access the current value, apply the procedure with no arguments:
+
+  (define p (make-parameter 10))
+  (p) => 10
+
+To provide a new value for the parameter in a dynamic extent, use
+`parameterize':
+
+  (parameterize ((p 20))
+    (p)) => 20
+  (p) => 10
+
+The value outside of the dynamic extent of the body is unaffected.  To
+update the current value, apply it to one argument:
+
+  (p 20) => 10
+  (p) => 20
+
+As you can see, the call that updates a parameter returns its previous
+value.
+
+All values for the parameter are first run through the CONV procedure,
+including INIT, the initial value.  The default CONV procedure is the
+identity procedure.  CONV is commonly used to ensure some set of
+invariants on the values that a parameter may have."
   (let ((fluid (make-fluid (conv init))))
     (make-struct <parameter> 0
                  (case-lambda
@@ -2938,6 +2966,22 @@ but it fails to load."
                           prev)))
                  fluid conv)))
 
+(define* (fluid->parameter fluid #:optional (conv (lambda (x) x)))
+  "Make a parameter that wraps a fluid.
+
+The value of the parameter will be the same as the value of the fluid.
+If the parameter is rebound in some dynamic extent, perhaps via
+`parameterize', the new value will be run through the optional CONV
+procedure, as with any parameter.  Note that unlike `make-parameter',
+CONV is not applied to the initial value."
+  (make-struct <parameter> 0
+               (case-lambda
+                 (() (fluid-ref fluid))
+                 ((x) (let ((prev (fluid-ref fluid)))
+                        (fluid-set! fluid (conv x))
+                        prev)))
+               fluid conv))
+
 (define (parameter? x)
   (and (struct? x) (eq? (struct-vtable x) <parameter>)))
 
@@ -2972,15 +3016,7 @@ but it fails to load."
 ;;; Current ports as parameters.
 ;;;
 
-(let ((fluid->parameter
-       (lambda (fluid conv)
-         (make-struct <parameter> 0
-                      (case-lambda
-                        (() (fluid-ref fluid))
-                        ((x) (let ((prev (fluid-ref fluid)))
-                               (fluid-set! fluid (conv x))
-                               prev)))
-                      fluid conv))))
+(let ()
   (define-syntax-rule (port-parameterize! binding fluid predicate msg)
     (begin
       (set! binding (fluid->parameter (module-ref (current-module) 'fluid)
@@ -3011,6 +3047,17 @@ but it fails to load."
 
 
 
+;;;
+;;; Languages.
+;;;
+
+;; The language can be a symbolic name or a <language> object from
+;; (system base language).
+;;
+(define current-language (make-parameter 'scheme))
+
+
+
 
 ;;; {Running Repls}
 ;;;
diff --git a/module/ice-9/eval-string.scm b/module/ice-9/eval-string.scm
index 27448d7..649551d 100644
--- a/module/ice-9/eval-string.scm
+++ b/module/ice-9/eval-string.scm
@@ -1,6 +1,6 @@
 ;;; Evaluating code from users
 
-;;; Copyright (C) 2011 Free Software Foundation, Inc.
+;;; Copyright (C) 2011, 2013 Free Software Foundation, Inc.
 
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
@@ -30,7 +30,7 @@
       (lookup-language x)))
 
 (define* (read-and-eval port #:key (lang (current-language)))
-  (with-fluids ((*current-language* (ensure-language lang)))
+  (parameterize ((current-language (ensure-language lang)))
     (define (read)
       ((language-reader (current-language)) port (current-module)))
     (define (eval exp)
diff --git a/module/ice-9/top-repl.scm b/module/ice-9/top-repl.scm
index d43436c..3027297 100644
--- a/module/ice-9/top-repl.scm
+++ b/module/ice-9/top-repl.scm
@@ -1,7 +1,7 @@
 ;;; -*- mode: scheme; coding: utf-8; -*-
 
 ;;;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-;;;;   2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+;;;;   2005, 2006, 2007, 2008, 2009, 2010, 2011, 2013 Free Software 
Foundation, Inc.
 ;;;;
 ;;;; This library is free software; you can redistribute it and/or
 ;;;; modify it under the terms of the GNU Lesser General Public
@@ -73,6 +73,6 @@
                         "warning: failed to install locale: ~a~%"
                         (strerror (car errno))))))
 
-       (let ((status (start-repl 'scheme)))
+       (let ((status (start-repl (current-language))))
          (run-hook exit-hook)
          status)))))
diff --git a/module/system/base/compile.scm b/module/system/base/compile.scm
index 0e44f36..f92ca7d 100644
--- a/module/system/base/compile.scm
+++ b/module/system/base/compile.scm
@@ -152,7 +152,7 @@
         file)
       comp)))
 
-(define* (compile-and-load file #:key (from 'scheme) (to 'value)
+(define* (compile-and-load file #:key (from (current-language)) (to 'value)
                            (env (current-module)) (opts '())
                            (canonicalization 'relative))
   (with-fluids ((%file-port-name-canonicalization canonicalization))
diff --git a/module/system/base/language.scm b/module/system/base/language.scm
index 5b27bc9..81b43b7 100644
--- a/module/system/base/language.scm
+++ b/module/system/base/language.scm
@@ -1,6 +1,6 @@
 ;;; Multi-language support
 
-;; Copyright (C) 2001, 2009, 2010, 2011 Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2009, 2010, 2011, 2013 Free Software Foundation, Inc.
 
 ;; This library is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU Lesser General Public
@@ -30,7 +30,9 @@
             lookup-compilation-order lookup-decompilation-order
             invalidate-compilation-cache! default-environment
 
-            *current-language* current-language))
+            *current-language*)
+
+  #:re-export (current-language))
 
 
 ;;;
@@ -111,7 +113,5 @@
 ;;; Current language
 ;;;
 
-(define *current-language* (make-fluid 'scheme))
-
-(define (current-language)
-  (fluid-ref *current-language*))
+;; Deprecated; use current-language instead.
+(define *current-language* (parameter-fluid current-language))
diff --git a/module/system/repl/command.scm b/module/system/repl/command.scm
index ae8bdea..c4e9e2c 100644
--- a/module/system/repl/command.scm
+++ b/module/system/repl/command.scm
@@ -1,6 +1,6 @@
 ;;; Repl commands
 
-;; Copyright (C) 2001, 2009, 2010, 2011 Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2009, 2010, 2011, 2013 Free Software Foundation, Inc.
 
 ;; This library is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU Lesser General Public
@@ -446,7 +446,7 @@ Change languages."
         (cur (repl-language repl)))
     (format #t "Happy hacking with ~a!  To switch back, type `,L ~a'.\n"
             (language-title lang) (language-name cur))
-    (fluid-set! *current-language* lang)
+    (current-language lang)
     (set! (repl-language repl) lang)))
 
 
diff --git a/module/system/repl/repl.scm b/module/system/repl/repl.scm
index f7b0229..7d2b7c8 100644
--- a/module/system/repl/repl.scm
+++ b/module/system/repl/repl.scm
@@ -1,6 +1,6 @@
 ;;; Read-Eval-Print Loop
 
-;; Copyright (C) 2001, 2009, 2010, 2011 Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2009, 2010, 2011, 2013 Free Software Foundation, Inc.
 
 ;; This library is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU Lesser General Public
@@ -132,9 +132,9 @@
 ;;;
 
 (define* (start-repl #:optional (lang (current-language)) #:key debug)
-  ;; ,language at the REPL will fluid-set! the *current-language*.  Make
-  ;; sure that it does so in a new scope.
-  (with-fluids ((*current-language* lang))
+  ;; ,language at the REPL will update the current-language.  Make
+  ;; sure that it does so in a new dynamic scope.
+  (parameterize ((current-language lang))
     (run-repl (make-repl lang debug))))
 
 ;; (put 'abort-on-error 'scheme-indent-function 1)


hooks/post-receive
-- 
GNU Guile



reply via email to

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