chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] hash-table-walk + hash-table-delete!


From: Kon Lovett
Subject: Re: [Chicken-users] hash-table-walk + hash-table-delete!
Date: Mon, 5 Mar 2007 18:54:25 -0800

On Mar 5, 2007, at 12:12 PM, Graham Fawcett wrote:

On 3/5/07, Kon Lovett <address@hidden> wrote:
On Mar 5, 2007, at 11:23 AM, Graham Fawcett wrote:
>> However I think a '(hash-table-remove! hash-table (-> key value
>> boolean))' procedure should be added to "extras.scm" just to be
>> "safe".
>
> Could you please explain that signature? I don't know how to interpret
> your (-> ...) form.

A strict prefix form:

(-> key value boolean) is (key value -> boolean) but should be
(object object -> boolean) since there are no key & value types.

Thanks. I thought it looked like Haskell, and I wasn't that far off.
:-) Wouldn't it be '(hash-table-remove! (-> hash-table key value
boolean)) ? Or do you write it as you did because the procedure
mutates the hash-table?

And lastly, are you passing both key and value in for correctness'
sake (in lieu of passing in the actual bucket, to which we don't have
a reference in a hash-table-walk), or would your implementation
actually test for equality on both before removing?

The idea was hash-table-remove! will take 2 parameters, a hash-table & a predicate. The predicate, (object object -> boolean), will return #t when the entry is to be deleted; kinda like SRFI-1 remove!. This allows conditioning the delete operation on all safely available data.

With hash-table-remove! weaker operations can be defined,
like (hash-table-remove!/keys hash-table KEY0 ...).


Graham





reply via email to

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