Re: [Scheme-reports] Seeking review of sets and hash tables proposals taylanbayirli@gmail.com (26 May 2013 10:14 UTC)
Re: [Scheme-reports] Seeking review of sets and hash tables proposals Alaric Snell-Pym (27 May 2013 22:00 UTC)

Re: [Scheme-reports] Seeking review of sets and hash tables proposals Alaric Snell-Pym 27 May 2013 21:58 UTC

On 27/05/13 21:59, John Cowan wrote:
> Alexey Radul scripsit:

>>> So far I haven't heard about any *actual* cases of people requiring
>>> specialized equivalence predicates, though it's easy to make up
>>> hypotheticals.
>>
>> Really?
>>
>> How about record types?  equal? is not specified to compare thei
>> contents recursively, so if I want those semantics I have to force
>> them with a custom equivalence predicate, and therefore a custom hash
>> function.  I have written a hash function because of this, so this
>> meets your criterion of non-hypotheticalness.
>
> You are the first person to say so.

I've often used records as hash keys in various languages. I think the
last example that comes to mind was in C and involved a struct type with
a few fields that contained a compound identifier; something like a
parsed represetantion of a URI.

>> How about sets?  Suppose I want to use sets as keys in a hash table,
>> with set=? as the equivalence predicate?
>
> What's the practical application of sets as keys?

I think I might have used one of these, too, in Python, when doing
something graph-theoretical, but I'm not certain :-)

But I think that "why would you want to do that?" is not a very good
position to be taking here. For every conceivable use case, we should be
sure to have an answer to "So how do I do this, then?". If the answer is
"Don't use your desired type as a key, instead project it into a list or
something you can compare with equal? and store the original inside the
value using a record type", then so be it, but we should make sure
that's a satisfactory answer to most.

However, it doesn't seem too hard to me to allow truly universal data
structures, perhaps using Taylor Campbell's reified ontologies, as
discussed earlier...

ABS

--
Alaric Snell-Pym
http://www.snell-pym.org.uk/alaric/

_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports