[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] hash-table-update!/default is broken
From: |
felix winkelmann |
Subject: |
Re: [Chicken-users] hash-table-update!/default is broken |
Date: |
Wed, 22 Feb 2006 07:53:56 +0100 |
Thanks, Thomas. Patch is applied.
cheers,
felix
On 2/21/06, Thomas Chust <address@hidden> wrote:
> 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
>
> _______________________________________________
> Chicken-users mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/chicken-users
>
>
>
>