guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] GNU Guile branch, srfi-41, updated. v2.0.7-212-g3972e7e


From: Mark H Weaver
Subject: [Guile-commits] GNU Guile branch, srfi-41, updated. v2.0.7-212-g3972e7e
Date: Wed, 20 Mar 2013 23:50:05 +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=3972e7e1b4604857f18ae2cfb6c694754b961e31

The branch, srfi-41 has been updated
       via  3972e7e1b4604857f18ae2cfb6c694754b961e31 (commit)
      from  22ee2f7dc985ffadaf5603256eab94a8c650759c (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 3972e7e1b4604857f18ae2cfb6c694754b961e31
Author: Mark H Weaver <address@hidden>
Date:   Wed Mar 20 19:45:42 2013 -0400

    Tweaks to srfi-41.scm.
    
    * module/srfi/srfi-41.scm: Include relevant copyright notice for the
      copy of the code from srfi-45.scm.  Explain in more detail why it's
      there.
      (%stream-null): New variable.
      (stream-null, stream-null?): Use %stream-null.
      (stream-car, stream-cdr): Avoid double-forcing the promise.
      (stream-take): Check (zero? n) before checking (stream-null? strm),
      to avoid forcing any more than necessary.

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

Summary of changes:
 module/srfi/srfi-41.scm |   62 ++++++++++++++++++++++++++++++++++++----------
 1 files changed, 48 insertions(+), 14 deletions(-)

diff --git a/module/srfi/srfi-41.scm b/module/srfi/srfi-41.scm
index 9e82c99..50e310b 100644
--- a/module/srfi/srfi-41.scm
+++ b/module/srfi/srfi-41.scm
@@ -81,9 +81,38 @@
     ((_ name syntax)
      (define-syntax name syntax))))
 
-;;; Copy-and-paste of Mark H. Weaver's version of SRFI 45. Once we have
-;;; better support for creating an independent promise type, we'll use
-;;; that instead.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; Here we include a copy of the code of srfi-45.scm (but with renamed
+;; identifiers), in order to create a new promise type that's disjoint
+;; from the promises created by srfi-45.  Ideally this should be done
+;; using a 'make-promise-type' macro that instantiates a copy of this
+;; code, but a psyntax bug in Guile 2.0 prevents this from working
+;; properly: <http://bugs.gnu.org/13995>.  So for now, we duplicate the
+;; code.
+
+;; Copyright (C) 2010, 2011, 2013 Free Software Foundation, Inc.
+;; Copyright (C) 2003 André van Tonder. All Rights Reserved.
+
+;; Permission is hereby granted, free of charge, to any person
+;; obtaining a copy of this software and associated documentation
+;; files (the "Software"), to deal in the Software without
+;; restriction, including without limitation the rights to use, copy,
+;; modify, merge, publish, distribute, sublicense, and/or sell copies
+;; of the Software, and to permit persons to whom the Software is
+;; furnished to do so, subject to the following conditions:
+
+;; The above copyright notice and this permission notice shall be
+;; included in all copies or substantial portions of the Software.
+
+;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+;; BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+;; ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+;; SOFTWARE.
 
 (define-record-type stream-promise (make-stream-promise val) stream-promise?
   (val stream-promise-val stream-promise-val-set!))
@@ -117,15 +146,20 @@
                             (stream-promise-val-set! promise* content)))
                  (stream-force promise))))))
 
+;;
+;; End of the copy of the code from srfi-45.scm
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
 ;;; Primitive stream functions and macros: (streams primitive)
 
 (define stream? stream-promise?)
 
-(define stream-null (stream-eager '(stream . null)))
+(define %stream-null '(stream . null))
+(define stream-null (stream-eager %stream-null))
 
 (define (stream-null? obj)
   (and (stream-promise? obj)
-       (eqv? (stream-force obj) (stream-force stream-null))))
+       (eqv? (stream-force obj) %stream-null)))
 
 (define-record-type stream-pare (make-stream-pare kar kdr) stream-pare?
   (kar stream-kar)
@@ -138,16 +172,16 @@
   (stream-eager (make-stream-pare (stream-delay obj) (stream-lazy strm))))
 
 (define (stream-car strm)
-  (unless (stream-pair? strm)
-    (must stream? strm 'stream-car "non-stream")
-    (must-not stream-null? strm 'stream-car "null stream"))
-  (stream-force (stream-kar (stream-force strm))))
+  (must stream? strm 'stream-car "non-stream")
+  (let ((pare (stream-force strm)))
+    (must stream-pare? pare 'stream-car "null stream")
+    (stream-force (stream-kar pare))))
 
 (define (stream-cdr strm)
-  (unless (stream-pair? strm)
-    (must stream? strm 'stream-cdr "non-stream")
-    (must-not stream-null? strm 'stream-cdr "null stream"))
-  (stream-kdr (stream-force strm)))
+  (must stream? strm 'stream-cdr "non-stream")
+  (let ((pare (stream-force strm)))
+    (must stream-pare? pare 'stream-cdr "null stream")
+    (stream-kdr pare)))
 
 (define-syntax-rule (stream-lambda formals body0 body1 ...)
   (lambda formals (stream-lazy (begin body0 body1 ...))))
@@ -403,7 +437,7 @@
   (must integer? n 'stream-take "non-integer argument")
   (must-not negative? n 'stream-take "negative argument")
   (stream-let recur ((n n) (strm strm))
-    (if (or (stream-null? strm) (zero? n)) stream-null
+    (if (or (zero? n) (stream-null? strm)) stream-null
         (stream-cons (stream-car strm) (recur (1- n) (stream-cdr strm))))))
 
 (define (stream-take-while pred? strm)


hooks/post-receive
-- 
GNU Guile



reply via email to

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