Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make-comparator rejects hash procedure returned by srfi-69 hash-table-hash-function #777

Closed
arvyy opened this issue Aug 15, 2021 · 1 comment

Comments

@arvyy
Copy link

arvyy commented Aug 15, 2021

Version 0.9.10

(import (scheme base) (srfi 69) (srfi 128))
(define hash-proc (hash-table-hash-function (make-hash-table)))
(procedure? hash-proc) ;; => #t
(make-comparator string? equal? #f hash-proc)

throws

*** ERROR: make-comparator needs a procedure or #f as hash, but got: #<closure ((hash-table-hash-function hash-table-hash-function) obj bound)>
@shirok
Copy link
Owner

shirok commented Aug 15, 2021

Ah, I see. Srfi-69 has a peculiarity that its hash function takes second argument (bound), and it is incompatible with comparators and other hash-table utilities (both built-in and (scheme hash-table)).

My srfi-69 implementation of hash-table-hash-function actually wraps the table's hash function to allow the second argument. So it's not the same hash-table-hash-function in (scheme hash-table).

I reread srfi-69 and it is not clear that its hash function must take the second argument, though. Reference implementation does require it, but there's no mention in the spec text. So I'll change srfi-69 implementation to return a hash function that takes optional second argument.

shirok added a commit that referenced this issue Aug 15, 2021
Make srfi-69's hash function's second argument always optional.

#777
@shirok shirok closed this as completed Sep 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants