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-15-18-g15


From: Andy Wingo
Subject: [Guile-commits] GNU Guile branch, master, updated. release_1-9-15-18-g15b06ca
Date: Wed, 09 Feb 2011 19:53:38 +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=15b06ca9cee69509fef83928fa492c51c8292bb7

The branch, master has been updated
       via  15b06ca9cee69509fef83928fa492c51c8292bb7 (commit)
       via  c5f30c4cba204114008b8ddc8ecea5a081be69b7 (commit)
      from  9970cf67080b48ec35680c70146500428b47bf3e (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 15b06ca9cee69509fef83928fa492c51c8292bb7
Author: Andy Wingo <address@hidden>
Date:   Wed Feb 9 20:54:36 2011 +0100

    readline uses define-once
    
    * guile-readline/ice-9/readline.scm: Use define-once.

commit c5f30c4cba204114008b8ddc8ecea5a081be69b7
Author: Andy Wingo <address@hidden>
Date:   Wed Feb 9 20:54:22 2011 +0100

    add define-once
    
    * module/ice-9/boot-9.scm (define-once): New syntax.
    
    * doc/ref/api-binding.texi (Top Level):
    * NEWS: Add notes about define-once.

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

Summary of changes:
 NEWS                              |    5 +++++
 doc/ref/api-binding.texi          |   19 ++++++++++++++++++-
 guile-readline/ice-9/readline.scm |   20 ++++++++++----------
 module/ice-9/boot-9.scm           |    5 +++++
 4 files changed, 38 insertions(+), 11 deletions(-)

diff --git a/NEWS b/NEWS
index 27b52ae..7912259 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,11 @@ latest prerelease, and a full NEWS corresponding to 1.8 -> 
2.0.
 
 Changes since the 1.9.15 prerelease:
 
+** New syntax: define-once
+
+`define-once' is like Lisp's `defvar': it creates a toplevel binding,
+but only if one does not exist already.
+
 ** Improved exactness handling for complex number parsing
 
 When parsing non-real complex numbers, exactness specifiers are now
diff --git a/doc/ref/api-binding.texi b/doc/ref/api-binding.texi
index 60af456..c97ae73 100644
--- a/doc/ref/api-binding.texi
+++ b/doc/ref/api-binding.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, 2009, 
2010
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2009, 
2010, 2011
 @c   Free Software Foundation, Inc.
 @c See the file guile.texi for copying conditions.
 
@@ -88,6 +88,23 @@ longer visible.
 Attention: Scheme definitions inside local binding constructs
 (@pxref{Local Bindings}) act differently (@pxref{Internal Definitions}).
 
+Many people end up in a development style of adding and changing
+definitions at runtime, building out their program without restarting
+it.  (You can do this using @code{reload-module}, the @code{reload} REPL
+command, the @code{load} procedure, or even just pasting code into a
+REPL.)  If you are one of these people, you will find that sometimes you
+there are some variables that you @emph{don't} want to redefine all the
+time.  For these, use @code{define-once}.
+
address@hidden defvar
address@hidden {Scheme Syntax} define-once name value
+Create a top level variable named @var{name} with value @var{value}, but
+only if @var{name} is not already bound in the current module.
address@hidden deffn
+
+Old Lispers probably know @code{define-once} under its Lisp name,
address@hidden
+
 
 @node Local Bindings
 @subsection Local Variable Bindings
diff --git a/guile-readline/ice-9/readline.scm 
b/guile-readline/ice-9/readline.scm
index 36f805f..a9f7cdc 100644
--- a/guile-readline/ice-9/readline.scm
+++ b/guile-readline/ice-9/readline.scm
@@ -1,6 +1,6 @@
 ;;;; readline.scm --- support functions for command-line editing
 ;;;;
-;;;;   Copyright (C) 1997, 1999, 2000, 2001, 2002, 2006, 2009, 2010 Free 
Software Foundation, Inc.
+;;;;   Copyright (C) 1997, 1999, 2000, 2001, 2002, 2006, 2009, 2010, 2011 Free 
Software Foundation, Inc.
 ;;;; 
 ;;;; This program is free software; you can redistribute it and/or modify
 ;;;; it under the terms of the GNU General Public License as published by
@@ -73,11 +73,11 @@
 ;;; Dirk:FIXME:: If the-readline-port, input-port or output-port are closed,
 ;;; guile will enter an endless loop or crash.
 
-(define new-input-prompt "")
-(define continuation-prompt "")
-(define input-port (current-input-port))
-(define output-port (current-output-port))
-(define read-hook #f)
+(define-once new-input-prompt "")
+(define-once continuation-prompt "")
+(define-once input-port (current-input-port))
+(define-once output-port (current-output-port))
+(define-once read-hook #f)
 
 (define (make-readline-port)
   (let ((history-buffer #f))
@@ -115,10 +115,10 @@
 ;;; everything except the prompt.  And don't forget the
 ;;; compile/load/run phase distinctions.  Also, the readline library
 ;;; isn't reentrant.
-(define the-readline-port #f)
+(define-once the-readline-port #f)
 
-(define history-variable "GUILE_HISTORY")
-(define history-file (string-append (getenv "HOME") "/.guile_history"))
+(define-once history-variable "GUILE_HISTORY")
+(define-once history-file (string-append (getenv "HOME") "/.guile_history"))
 
 (define-public readline-port
   (let ((do (lambda (r/w)
@@ -215,7 +215,7 @@
        (lambda ()
          (set! *readline-completion-function* old-completer)))))
 
-(define readline-repl-reader
+(define-once readline-repl-reader
   (let ((boot-9-repl-reader repl-reader))
     (lambda* (repl-prompt #:optional (reader (fluid-ref current-reader)))
       (let ((port (current-input-port)))
diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index fe7f2b2..f706a71 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -473,6 +473,11 @@ If there is no handler at all, Guile prints an error and 
then exits."
        (with-syntax ((s (datum->syntax x (syntax-source x))))
          #''s)))))
 
+(define-syntax define-once
+  (syntax-rules ()
+    ((_ sym val)
+     (define sym
+       (if (module-locally-bound? (current-module) 'sym) sym val)))))
 
 
 


hooks/post-receive
-- 
GNU Guile



reply via email to

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