3 ms·
in cl, you can use defsetf to almost do the same. as a matter of fact, taking a cue from arc, you can write a macro like: (defmacro deftable (name) `(pro
by utx00 17y ago
in cl, you can use defsetf to almost do the same. as a matter of fact, taking a cue from arc, you can write a macro like:
(defmacro deftable (name)
`(progn
(defparameter ,name (make-hash-table))
(defun ,name (k)
(gethash k ,name))
(defsetf ,name (k) (v)
`(setf (gethash ,k ,',name) ,v))))
now you can do:
(deftable client), which creates the hashtable, and then
(client 'phone) will retrieve the value,
(setf (client 'phone) '4444444) will set the value.