I’m looking for a possibly non-verbose portable way to initialize a hash table in Common Lisp. E.g. something that works for constant hash tables, but also to pre-load variable hashes. In CLISP I am using:
(defconstant +my-map+ #S(HASH-TABLE :TEST FASTHASH-EQ
(key1 . "value1")
...
(keyN . "valueN")
))
but unfortunately this format only works on CLISP.
One can programmatically construct a hash table at read time:
#.is used for read time evaluation. The compiler then will dump the hash table to the FASL file.This can then be compiled:
Using SBCL:
Creating a hash table as a function: