8.16.0.1
8.2 Equality and Hashing Implementations
(require rebellion/equal+hash) | package: rebellion |
procedure
(make-accessor-based-equal+hash accessor size) → equal+hash/c accessor : (-> any/c natural? any/c) size : natural?
Builds an equality-checking function, a hashing function, and a secondary
hashing function suitable for use with prop:equal+hash. These
functions extract size fields from values using accessor and
recursively compare and hash them. This function is typically not used
directly; instead clients are expected to use one of make-struct-equal+hash or default-tuple-equal+hash.
value
= (list/c procedure? procedure? procedure?)
8.2.1 Struct Equality and Hashing
(require rebellion/equal+hash/struct) | package: rebellion |
procedure
(make-struct-equal+hash descriptor) → equal+hash/c
descriptor : struct-descriptor?
Builds an equality-checking function, a hashing function, and a secondary
hashing function suitable for use with prop:equal+hash, each of which
operate on instances of descriptor. All fields in descriptor
are compared and hashed by the returned procedures. This causes equal?
to behave roughly the same as it does on transparent structure types.
Examples:
> (struct opaque-point (x y)) > (equal? (opaque-point 1 2) (opaque-point 1 2)) #f
> (define point-descriptor (make-struct-implementation #:name 'point #:immutable-fields 2 #:property-maker (λ (descriptor) (define equal+hash (make-struct-equal+hash descriptor)) (list (cons prop:equal+hash equal+hash))))) > (define point (struct-descriptor-constructor point-descriptor)) > (equal? (point 1 2) (point 1 2)) #t