
CMUCL and EQUAL hash tables
Quote:
>| I just noticed that I can't use arrays with fill-pointers as hash keys in
>| EQUAL hash tables. The following transcript should explain the problem:
> and 18.1.2 Modifying Hash Table Keys in ANSI X3.226-1994 Common Lisp
> explains why.
> there never was a substitute for reading the specification. go grab it
> from <URL:http://www.harlequin.com/education/books/HyperSpec/>.
>| Of course, I expect ...
> well, there's your problem right there: why did you expect this?
>#:Erik
>--
Me thinks Fredrik's got every right to expect this behaviour (which BTW
works in ACL as expected). The essential part of 18.1.2 reads:
If an object O1 is used as a key in a hash table H and is THEN visibly modified with
regard to the equivalence test of H, then the consequences are unspecified if O1,
or any object O2 equivalent to O1 under the equivalence test (either before or after
the modification), is used as a key in further operations on H.
At the point of using the key there was NO visible modification present
as also the successful (equal . ..) proved. So the hash-table lookup should
work as expected.
A totally different discussion would be the question of using modifyable keys
for storing stuff in hash-tables, which might easily lead to disaster.
But in the example given, the "storage key" was a simple string, whereas the
retrieval key was an array using a fill-pointer which happended to be EQUAL
at retrieval time. This seems like a totally reasonable usage pattern, e.g.
you have kind of symbol-table and parse some string collecting its characters
into an adjustable array and do some (hash-)table lookup after the token is
completed.
Bernhard
--
--------------------------------------------------------------------------
Bernhard Pfahringer
Austrian Research Institute for http://www.ai.univie.ac.at/~bernhard/