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

Kevin Reid kpreid at switchb.org
Sun Jul 14 19:29:59 PDT 2013


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.

> On Jul 14, 2013, at 4:49 PM, Tom Emerson wrote:
>> On Sun, Jul 14, 2013 at 3:53 PM, Ron Garret <ron at flownet.com> wrote:
>> I need a string= hash table, which is not in the standard.  It appears that CCL can actually make one:
>> 
>> (make-hash-table :test 'string= :hash-function 'sxhash)
>> 
>> This seems to do the Right Thing, but  it's not documented.  Is it safe to use this feature?

-- 
Kevin Reid                                  <http://switchb.org/kpreid/>




More information about the Openmcl-devel mailing list