[Openmcl-devel] Is it safe to make hash tables with non-standard tests?

Ron Garret ron at flownet.com
Mon Jul 15 02:44:54 UTC 2013


On Jul 14, 2013, at 7:29 PM, Kevin Reid wrote:

> On Jul 14, 2013, at 18:02, Ron Garret <ron at flownet.com> wrote:
> 
>> EQUALP doesn't do the Right Thing with symbols:
>> 
>> ? (equalp 'foo "FOO")
>> NIL
>> ? (string= 'foo "FOO")
>> T
> 
> If you want to make use of that equality, then it is in principle unsafe to use SXHASH as the hash function, because there is no guarantee (as far as I see in CLHS) that (= (sxhash 'foo) (sxhash "FOO")); therefore such a hash table may be inconsistent.
> 
> Given that you aren't looking for portability, this is not a serious problem (assuming CCL does have this equality), but I think it's worth noting the dependence on that.


I was actually going to use (sxhash (string-upcase (princ-to-string thing))) as the hash function, and STRING-EQUAL as the test.

rg




More information about the Openmcl-devel mailing list