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-11-180-g3


From: Julian Graham
Subject: [Guile-commits] GNU Guile branch, master, updated. release_1-9-11-180-g3fdc1d0
Date: Wed, 14 Jul 2010 05:16:26 +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=3fdc1d05aeb2c0851e696b8fd83a70b70c5eff5f

The branch, master has been updated
       via  3fdc1d05aeb2c0851e696b8fd83a70b70c5eff5f (commit)
      from  5b69315ed3993cceb498f0e05183e4da03dbc1c3 (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 3fdc1d05aeb2c0851e696b8fd83a70b70c5eff5f
Author: Julian Graham <address@hidden>
Date:   Wed Jul 14 01:16:19 2010 -0400

    Fix argument passing for external hash functions in `(rnrs hashtables)'.
    Guile implements this library in terms of SRFI-69, which is a bit vague on
    the arity of hash functions, whereas `(rnrs hashtables)' explicitly
    specifies unary ones.
    
    * module/rnrs/hashtables.scm (wrap-hash-function): Assume SRFI-69 will pass
      the table capacity as the second argument; return the result of proc
      modulo the capacity.
    
    * test-suite/tests/r6rs-hashtables.test (make-hashtable): New test case for
      hash functions that return large values.

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

Summary of changes:
 module/rnrs/hashtables.scm            |    6 ++++--
 test-suite/tests/r6rs-hashtables.test |    8 +++++++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/module/rnrs/hashtables.scm b/module/rnrs/hashtables.scm
index 48ca5f3..98d2d76 100644
--- a/module/rnrs/hashtables.scm
+++ b/module/rnrs/hashtables.scm
@@ -45,7 +45,8 @@
   (import (rename (only (guile) string-hash-ci 
                                 string-hash 
                                 hashq 
-                                hashv 
+                                hashv
+                                modulo
                                 *unspecified*
                                 @@)
                  (string-hash-ci string-ci-hash))
@@ -88,7 +89,8 @@
   (define hashtable-mutable? r6rs:hashtable-mutable?)
 
   (define hash-by-value ((@@ (srfi srfi-69) caller-with-default-size) hashv))
-  (define (wrap-hash-function proc) (lambda (key obj) (proc key)))
+  (define (wrap-hash-function proc) 
+    (lambda (key capacity) (modulo (proc key) capacity)))
 
   (define* (make-eq-hashtable #:optional k)
     (make-r6rs-hashtable 
diff --git a/test-suite/tests/r6rs-hashtables.test 
b/test-suite/tests/r6rs-hashtables.test
index 9d5c730..c7812c5 100644
--- a/test-suite/tests/r6rs-hashtables.test
+++ b/test-suite/tests/r6rs-hashtables.test
@@ -45,7 +45,13 @@
           (abs-hashtable (make-hashtable abs abs-eqv?)))
       (hashtable-set! abs-hashtable -4 #t)
       (and (not (hashtable-contains? abs-hashtable 6))
-          (hashtable-contains? abs-hashtable 4)))))      
+          (hashtable-contains? abs-hashtable 4))))
+
+  (pass-if "hash function value used modulo capacity"
+    (let* ((constant-hash (lambda (x) most-positive-fixnum))
+          (constant-hashtable (make-hashtable constant-hash eq?)))
+      (hashtable-set! constant-hashtable 'foo 'bar)
+      (hashtable-contains? constant-hashtable 'foo))))
 
 (with-test-prefix "hashtable?"
   (pass-if "hashtable? is #t on hashtables"


hooks/post-receive
-- 
GNU Guile



reply via email to

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