| Been wondering at this. It seems that Arc allows one to use just about any object as a key in a hash table, but it seems that the semantics are all messed up. For instance, I have the following: arc> (= h (table))
#hash()
arc> (= h2 (table))
#hash()
arc> (= (h h2) 1)
1
arc> (h h2)
1
arc> (h (table))
1
So far, this seems to indicate that the value of the empty table is being used as the key, and not the specific instance of the empty table h2 that had been created. But then, when we modify h2: arc> (= (h2 1) 2)
2
arc> h2
#hash((1 . 2))
arc> (h h2)
nil
arc> h
#hash((#hash((1 . 2)) . 1))
arc> (h (table))
nil
What just happened here? In contrast, when we try to use conses as keys it seems to do something more reasonable but still strange: arc> (= h (table))
#hash()
arc> (= c '(1 2))
(1 2)
arc> (= (h c) 3)
3
arc> (h c)
3
arc> (h '(1 2))
3
arc> (scar c 3)
3
arc> c
(3 2)
arc> h
#hash(((3 2) . 3))
arc> (h '(3 2))
3
arc> (h '(1 2))
nil
I don't know how this can be done efficiently. Modifying any reference possibly requires a hash table to re-key? Seems like a bloody piece of work to implement. |