Reflect specification bug in definition of HASH-TABLE-UPDATE!.
authorTaylor R Campbell <campbell@mumble.net>
Mon, 21 Dec 2009 20:11:16 +0000 (15:11 -0500)
committerTaylor R Campbell <campbell@mumble.net>
Mon, 21 Dec 2009 20:11:16 +0000 (15:11 -0500)
We can't use HASH-TABLE/MODIFY! because the specification tacitly
permits the procedure to edit the hash table.  This was a silly
oversight in the SRFI document.

src/runtime/hashtb.scm

index a0fa9274c6f98fe5467d860cc38b998a223b4a08..e5fe7f8969b9c4c6543047422bba0b68d35fb69b 100644 (file)
@@ -840,19 +840,16 @@ USA.
        datum)))
 
 (define (hash-table-update! table key procedure #!optional get-default)
-  (hash-table/modify! table
-                     key
-                     (if (default-object? get-default)
-                         (lambda (datum)
-                           (if (eq? datum default-marker)
-                               (error:bad-range-argument key
-                                                         'HASH-TABLE-UPDATE!))
-                           (procedure datum))
-                         (lambda (datum)
-                           (procedure (if (eq? datum default-marker)
-                                          (get-default)
-                                          datum))))
-                     default-marker))
+  (hash-table-set!
+   table
+   key
+   (procedure
+    (hash-table-ref table
+                   key
+                   (if (default-object? get-default)
+                       (lambda ()
+                         (error:bad-range-argument key 'HASH-TABLE-UPDATE!))
+                       get-default)))))
 
 (define (hash-table-copy table)
   (guarantee-hash-table table 'HASH-TABLE-COPY)