fix make-comparator hash function arity in SRFI 128

This commit is contained in:
Adam R. Nelson 2020-01-11 11:58:31 -05:00
parent 48d6c35548
commit 6aacffc0e8
2 changed files with 15 additions and 2 deletions

View file

@ -1,7 +1,8 @@
(define-library (srfi 128)
(import (scheme base) (scheme char)
(srfi 27) (srfi 69) (srfi 95) (srfi 98) (srfi 151)
(only (chibi) fixnum? er-macro-transformer))
(only (chibi) fixnum? er-macro-transformer)
(only (chibi ast) opcode? procedure? procedure-arity procedure-variadic?))
(export
;; Predicates:
comparator? comparator-ordered? comparator-hashable?

View file

@ -1,12 +1,24 @@
(define-record-type Comparator
(make-comparator type-test equality ordering hash)
(%make-comparator% type-test equality ordering hash)
comparator?
(type-test comparator-type-test-predicate)
(equality comparator-equality-predicate)
(ordering comparator-ordering-predicate)
(hash comparator-hash-function))
(define (make-comparator type-test equality ordering hash)
(%make-comparator%
type-test
equality
ordering
(if (or (opcode? hash)
(not (procedure? hash))
(procedure-variadic? hash)
(> (procedure-arity hash) 1))
hash
(lambda (x . o) (hash x)))))
(define-syntax hash-bound
(er-macro-transformer
(lambda (expr rename compare)