Jesdisciple wrote:Ramarren: Wouldn't SYMBOL-MACROLET only call GETHASH multiple times? I was hoping to only go searching my hashtable for that index one time. However, I think I understand how a closure could do that... EDIT: Wait, no I don't. I was trying to use GETHASH to both set and then get the value.
SYMBOL-MACROLET would mean that (SETF GETHASH) would be called every time you set a hashtable, the same with closure. Do note that (SETF GETHASH) and GETHASH are separate functions. (setf (gethash ...) ...) is just a syntax to call the former.
In general, Common Lisp doesn't allow holding pointers into the inside of datastructures (which would be the primary uses of locatives), so there is no way to avoid the full set in hashtable. Well, looking at SBCL source (the great thing about open source Lisps, you can just use M-. in Slime and jump straight into the internals), the last key lookup is cached. But in general you cannot "save your place".
If your performance is bottlenecked by key hashing then your algorithm is likely suboptimal, and if it is not then why worry about it?