Guile Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scheme style auto-resizing hashtable (fwd)
jglascoe@jay.giss.nasa.gov writes:
>
> Here are much better names (I was going to make its behavior conditional
> on the type of the argument... not a good idea, I think):
>
> dictionary-add-dictionary! (err, dictionary-insert-dictionary!)
> dictionary-add-alist! (..., dictionary-insert-alist!)
>
> here's a new list of dictionary procedures
>
Here are my comments (other than s/dictionary/hash-table/g which I
mentioned in a previous message).
I'd like to see parameter signatures for these.
> constructors:
>
> make-dictionary
> make-dictionaryv
> make-dictionaryq
>
> behavior modifiers:
>
> dictionary-enable!
> dictionary-disable!
> dictionary-change-type!
>
Couldn't these all be encapsulated into a generic
disctionary-set-parameter!, it seems annoying to have so much
interface just to set a few tunable parameters.
> the big three basic operations:
>
> dictionary-insert!
> dictionary-lookup
> dictionary-remove!
>
In my opition, consistency is even more important than
meaningfulness. Hence, these should be renamed to `dictionary-set!',
`dictionary-ref' and `dictionary-delete!' respectively. Also there
should probably be a `dictionary-add!' which inserts a given key-value
cons cell, guaranteeing to share the memory.
> iterators and friends:
>
> dictionary-map <-> ???
> dictionary-foreach <-> ???
Er, that should be -for-each, not -foreach, again for consistency.
> dictionary-make-iterator -- perhaps add an "auto-grow"
> -- option to be toggled off until
> -- iterator is finished
> call-with-dictionary-iterator
>
> dictionary to whatever conversions:
>
> dictionary->alist -- was dictionary->items
> dictionary->keys
> dictionary->values
>
> whatever to dictionary "conversions":
>
> dictionary-insert-alist!
Although this might seem nice as a convenience,
(dictionary-insert-alist! my-dict my-assoc)
is barely shorter than the (IMO more clear)
(for-each (lambda (x) (dictionary-add! my-dict x)) my-assoc)
> dictionary-consume-alist! -- delete alist while
> -- inserting pairs (to conserve memory)
I don't understand how this can possibly work. You can't "delete" an
object in Scheme per se, you can only remove all references to it, at
which point it gets GC'd.
> dictionary-insert-dictionary!
> dictionary-consume-dictionary! -- delete buckets while
> -- inserting entries
>
Same points as above, except that it is vaguely meaningful to clear a
dictionary while copying it into another. Are these operations really
common enough that making the API bigger by including them directly is
a good thing?
> statistics:
>
> dictionary-stats
> dictionary-more-stats
>
`dictionary-stats' is gratuitous enough as it is that there don't need
to be two of them :-)
> the rest:
>
> dictionary-clear!
> dictionary-copy!
>
If anything I think a non-desctructive `dictionary-copy' would be more
useful than `dictionary-copy!'. The latter is unlikely to be much more
efficient, and it seems a nuisance to have to have a spare dictionary
object lying around to copy into.
- Maciej
Guile Home |
Main Index |
Thread Index