Stable Hash Tables
Bug #1725340 reported by
Paul F. Dietz
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
SBCL |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
Wishlist item: add a :STABLE keyword arg to MAKE-HASH-TABLE. When true, the resulting hash table is stable in the sense that iterating over the hash table will do so in the order that the items were inserted (with replacement of the value for an existing key not changing the order.)
The motivation for this is to enable a programmer to use hash tables deterministically, with the output being independent of the hash function or other details that could affect the iteration order.
To post a comment you must log in.
There are a myriad of variations that people would like. It doesn't make sense to add one keyword that adds this option per se to the builtin tables. It would be more useful to design a pluggable hash-table architecture where GETHASH and (SETF GETHASH) dispatch to table-specific code.
[I daren't say generic in the CLOS sense. Dispatch should be fast, the way our ANSI streams dispatch]
Things people would like:
* use less memory
* use different hash strategy
* preserve insertion order
* be lock-free
Those could have totally different code behind them. If make-hash-table is the universal constructor, it likely won't have a fixed set of keywords.
Anyway, hash-tables do preserve insertion order right now by accident so to speak, not by intent. Depending what you're trying to do, it may just work.