chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] hash-table-update!/default is broken


From: Thomas Chust
Subject: [Chicken-users] hash-table-update!/default is broken
Date: Tue, 21 Feb 2006 20:38:46 +0000 (GMT)

Hello,

the function hash-table-update!/default and also hash-table-update! on which it is based in CHICKEN do not behave as prescribed by SRFI-69:

$ csi
  @@@@@@@ @@@  @@@ @@@  @@@@@@@ @@@  @@@ @@@@@@@@ @@@  @@@
 !@@      @@!  @@@ @@! !@@      @@!  !@@ @@!      @@address@hidden@@@
 address@hidden      @address@hidden@address@hidden !!@ address@hidden      
@!@@address@hidden  @!!!:!   @!@@address@hidden
 :!!      !!:  !!! !!: :!!      !!: :!!  !!:      !!:  !!!
  :: :: :  :   : : :    :: :: :  :   ::: : :: ::: ::    :

Version 2, Build 301 - macosx-unix-gnu-ppc - [ libffi dload ptables ]
(c)2000-2005 Felix L. Winkelmann
#;1> (define ht (make-hash-table))
#;2> (hash-table-update!/default ht 'x add1 0)
#;3> (hash-table-ref ht 'x)
0

The correct return value would be 1 because SRFI-69 states:

Procedure: hash-table-update! hash-table key function [ thunk ] => undefined

Semantically equivalent to, but may be implemented more efficiently than, the following code:

(hash-table-set! hash-table key
                 (function (hash-table-ref hash-table key thunk)))

This means, that "function" has to be called, even if the key is not present in the hashtable, which CHICKEN fails to do.

A patch fixing extras.scm (created with darcs send) is attached.

cu,
Thomas

Attachment: hashtable-update.patches
Description: darcs patches for extras.scm


reply via email to

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