chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] functions for hash tables


From: Sven . Hartrumpf
Subject: Re: [Chicken-users] functions for hash tables
Date: Thu, 27 Jan 2005 21:48:08 +0100 (CET)

On 27 Jan 2005, felix winkelmann <address@hidden> wrote:
> > 1.
> > hash-table-update! is missing (although important).
> 
> If I understand this correctly, it's hash-table-set! with an update function,
> right?

Yes.

> Is this really that useful?

Without such a function, each modification of a hash table's value would
require two calls:

  hash-table-ref
AND
  hash-table-set!
(which calculates the hash for the key twice,
some more complications if the key is not in the hash table).

> > 3.
> > hash-table-ref is called hash-table-get in all other implementations.
> 
> Hm, I prefer -ref and -set!.

Ok. I see that many people want Chicken to be avantgard :-) Why not?
But there is a small asymmetry:
-ref and -set! work with numerical "keys" whose values  _always exist_ in
the given list/string/vector (otherwise an error would be triggered) -
while -put! might legally create a new key-value pair
and -get returns for a nonexisting key _without_ an error.

> > Gauche has an additional optional argument that specifies what is returned 
> > if
> > key is not present - might be a good extension.
> 
> Chicken has this.

Sorry, I should read the manual more closely.


Ciao
Sven

Attachment: pgprgcxqrtJhu.pgp
Description: PGP signature


reply via email to

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