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

Tom Emerson tremerson at gmail.com
Sun Jul 14 17:54:35 PDT 2013


What CLtL1 says isn't really relevant in 2013. There also isn't a need to
create a hash table for #'string= because that functionality is already
supported by the standard.

So the statement in Ron's message that a 'string= hashtable [...] is not in
the standard" is false, and there is no reason to use a non-standard
approach when the standard covers both this case and a #'string-equal case.

So while my response doesn't directly answer his exact question, it answers
it in a way that obviates the need for his original query.



On Sun, Jul 14, 2013 at 8:48 PM, Gary Byers <gb at clozure.com> wrote:

> If the question was "can TEST functions other than EQ/EQL/EQUAL/EQUALP
> be used non-portably in CCL, and should that be considered a supported
> extension that should be documented ?", the answer is "yes".  IIRC, in
> CLtL1 EQUALP wasn't a standard test function, and supporting arbitrary
> test functions (and user-provided hashing functions) was one way of
> supporting EQUALP as a test.
>
> If the question was "is this a non-portable extenstion ?" ... I don't
> think that that was the question.
>
> If the question was "is there a compelling reason to use a non-standard
> test function (other than typechecking and whatever the performance
> tradeoffs
> are at the moment), and is such a reason more compelling than portability
> concerns that one may or may not have ?" ... well, that's a good question
> to ask and one that different people can have good reasons to answer
> differently.
>
>
> On Sun, 14 Jul 2013, Tom Emerson wrote:
>
>  You don't need to: using 'equal as your test achieves the same result.
>> Welcome to Clozure Common Lisp Version 1.9-r15757 ?(LinuxX8664)!
>>
>> ? (defvar foo (make-hash-table :test 'equal))
>> #<HASH-TABLE :TEST EQUAL size 0/60 #x3020006F2C3D>
>> ? (setf (gethash "abc" foo) 100)
>> 100
>> ? (gethash "abc" foo)
>> 100
>> T
>> ? (gethash "ABC" foo)
>> NIL
>> NIL
>>
>> If instead you want the test to be string-equal then use 'equalp
>>
>> ? (setq foo (make-hash-table :test 'equalp))
>> #<HASH-TABLE :TEST EQUALP size 0/60 #x3020006F9D5D>
>> ? (setf (gethash "abc" foo) 100)
>> 100
>> ? (gethash "abc" foo)
>> 100
>> T
>> ? (gethash "ABC" foo)
>> 100
>> T
>>
>> This is portable: same results in SBCL.
>>
>>
>>
>> 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?
>>
>>       rg
>>
>>       ______________________________**_________________
>>       Openmcl-devel mailing list
>>       Openmcl-devel at clozure.com
>>       http://clozure.com/mailman/**listinfo/openmcl-devel<http://clozure.com/mailman/listinfo/openmcl-devel>
>>
>>
>>
>>
>> --
>> Tom Emerson
>> tremerson at gmail.com
>> http://www.dreamersrealm.net/**tree <http://www.dreamersrealm.net/tree>
>>
>>
>>


-- 
Tom Emerson
tremerson at gmail.com
http://www.dreamersrealm.net/tree
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20130714/a74c7b22/attachment.htm>


More information about the Openmcl-devel mailing list