Q: Can hash-table entries have property lists and, if no, what are the idiomatic alternatives?
As the manual explains, symbols can record miscellaneous information via symbol properties. I'd like to know if this applies to hash tables with symbols as keys.
Here's a toy example:
(setf hash-1 (make-hash-table)
hash-2 (make-hash-table))
(puthash :key-1 "val-1" hash-1)
(puthash :key-2 "val-2" hash-2)
Can I attach symbol properties to :key-1
-- and, particularly, different properties for the two hash tables -- for later inspection? I'm guessing no, as neither gethash
nor puthash
seem to offer facilities for manipulating the key -- only the value. (See also this thread.)
If that's correct, what is the idiomatic alternative to symbol properties for hash-table entries?
I could, for example, assign an alist as the value of a hash entry:
(puthash :key-2 '((:val "val-3") (:prop prop-1)) hash-1)
(puthash :key-2 '((:val "val-4") (:prop prop-2)) hash-2)
And then each entry has a value list and a "property" list:
(assq :val (gethash :key-2 hash-1)) ; => (:val "val-3")
(assq :prop (gethash :key-2 hash-1)) ; => (:prop prop-1)
(assq :val (gethash :key-2 hash-2)) ; => (:val "val-4")
(assq :prop (gethash :key-2 hash-2)) ; => (:prop prop-2)
That seems a little convoluted, however. Is there a cleaner way to do this?