Programmatore esperto di lisp, schema e clojure che passa a elisp da Python per automatizzare le attività di routine, quotidiane, di base: ho avuto un'enorme sorpresa da quanto segue ielm
ELISP> (setq h2 (make-hash-table))
#s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8 data ())
ELISP> (puthash "a" 1 h2)
1 (#o1, #x1, ?\C-a)
ELISP> (gethash "a" h2)
nil
eh? La chiave e il valore sembrano essere presenti:
ELISP> h2
#s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8 data ("a" 1))
/ schiaffeggia la fronte. Mi manca qualcosa di totalmente ovvio. Le informazioni dicono:
-- Function: gethash key table &optional default
This function looks up KEY in TABLE, and returns its associated
VALUE—or DEFAULT, if KEY has no association in TABLE.
grande. Vediamo se riusciamo gethasha restituire qualcosa di diverso da nil:
ELISP> (gethash "a" h2 'fubar)
fubar
Wow. Ok, sono molto più stupido di quanto pensassi. Cosa diavolo sto facendo di sbagliato?
:testparametro nel tuo esempio ...