Accessor GETHASH
gethash key hash-table &optional default => value, present-p
(setf (gethash key hash-table &optional default) new-value)
key - オブジェクト
hash-table - ハッシュテーブル
default - オブジェクト。デフォルトはnil。
value - オブジェクト
present-p - generalized-boolean
valueは、hash-tableの中にある、 キーがkeyとhash-tableの等価テストで 等しいとされたもののオブジェクトです。 そのようなエントリーが存在しないときは、 valueはdefaultになります。
もしエントリーが見つかったときはpresent-pはtrueであり、 それ以外はfalseです。
setfのgethashの使用は、 与えられたキーに関連付けられた値を修正するときか あるいは新しいエントリーを追加するときに使用されます。 gethashフォームがsetfのplaceで使用された場合、 defaultが与えられたときは 通常の左から右への評価ルールに従って評価されますが、 その値は無視されます。
(setq table (make-hash-table)) =>  #<HASH-TABLE EQL 0/120 32206334>
(gethash 1 table) =>  NIL, false
(gethash 1 table 2) =>  2, false
(setf (gethash 1 table) "one") =>  "one"
(setf (gethash 2 table "two") "two") =>  "two"
(gethash 1 table) =>  "one", true
(gethash 2 table) =>  "two", true
(gethash nil table) =>  NIL, false
(setf (gethash nil table) nil) =>  NIL 
(gethash nil table) =>  NIL, true
(defvar *counters* (make-hash-table)) =>  *COUNTERS*
(gethash 'foo *counters*) =>  NIL, false
(gethash 'foo *counters* 0) =>  0, false
(defmacro how-many (obj) `(values (gethash ,obj *counters* 0))) =>  HOW-MANY
(defun count-it (obj) (incf (how-many obj))) =>  COUNT-IT
(dolist (x '(bar foo foo bar bar baz)) (count-it x))
(how-many 'foo) =>  2
(how-many 'bar) =>  3
(how-many 'quux) =>  0なし。
なし。
なし。
第二返却値であるpresent-pは、 エントリーの不在か、 defaultの値を持つエントリーの存在かを、 区別するときに使用できます。