current-language is a parameter in boot-9
authorAndy Wingo <wingo@pobox.com>
Mon, 21 Jan 2013 10:21:19 +0000 (11:21 +0100)
committerAndy Wingo <wingo@pobox.com>
Tue, 22 Jan 2013 14:38:04 +0000 (15:38 +0100)
* 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.

doc/ref/compiler.texi
module/ice-9/boot-9.scm
module/ice-9/eval-string.scm
module/ice-9/top-repl.scm
module/system/base/compile.scm
module/system/base/language.scm
module/system/repl/command.scm
module/system/repl/repl.scm

index 25cf524..a88942d 100644 (file)
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
-@c Copyright (C)  2008, 2009, 2010
+@c 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
+@code{current-language} 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.
 
index a22ac8b..4efd753 100644 (file)
@@ -3047,6 +3047,17 @@ CONV is not applied to the initial value."
 
 
 \f
+;;;
+;;; Languages.
+;;;
+
+;; The language can be a symbolic name or a <language> object from
+;; (system base language).
+;;
+(define current-language (make-parameter 'scheme))
+
+
+\f
 
 ;;; {Running Repls}
 ;;;
index 27448d7..649551d 100644 (file)
@@ -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)
index d43436c..3027297 100644 (file)
@@ -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)))))
index 0e44f36..f92ca7d 100644 (file)
         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))
index 5b27bc9..81b43b7 100644 (file)
@@ -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))
 
 \f
 ;;;
 ;;; 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))
index ae8bdea..c4e9e2c 100644 (file)
@@ -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)))
 
 \f
index f7b0229..7d2b7c8 100644 (file)
@@ -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
 ;;;
 
 (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)