[R6RS] `eqv?' on immutable records

R. Kent Dybvig dyb at cs.indiana.edu
Mon May 14 11:38:48 EDT 2007


Incidentally, I'm guilty of defining record types with no fields to be
used only for their object identity, e.g., defining

  (define-record-type label)

and counting on each call to make-label returning a new object
distinguishable from all others via eq?.  I suspect other programmers have
done this as as well.  It is unfortunate if, in our zeal to facilitate the
construction of naive optimizing compilers, we don't allow this useful
paradigm.  So I am in favor of tagging all record instances, pairs, and
vectors, whether mutable or not.  I'm okay with allowing constants to be
commonized, so, for example:

  (let ([x '(a)]) (eq? x x)) ;=> #t
  (let ([x '(a b)]) (eq? (cdr x) (cdr x))) ;=> #t
  (eq? '(a) '(a)) ;=> #t or #f

On the other hand, I'm happy leaving unspecified how eq? behaves on
numbers and characters.  I don't feel strongly one way or another
about strings or bytevectors.

Kent



More information about the R6RS mailing list