[R6RS] `eqv?' on immutable records

Anton van Straaten anton at appsolutions.com
Mon May 14 14:20:50 EDT 2007


Kent wrote:
> 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.  

My zeal is purer than that.  Requiring that immutable values be tagged 
with a hidden identity other than their value is a rather non-functional 
behavior.  It doesn't make sense to me to impose this requirement on all 
values just to allow some values to have these semantics.  I'd rather 
have a way to specify object identity semantics when that's what's wanted.

For example, the record syntax could be extended with a new 'identity' 
case for the <record clause>.  The above example would then be 
implemented as:

   (define-record-type label (identity #t))

Immutable record types would default to (identity #f), so their 
instances would not be location-tagged.  Specifying (identity #t) would 
cause instances to have a location tag.

For mutable records, specifying (identity #t) would be redundant, and 
(identity #f) would (presumably) be disallowed.

Anton



More information about the R6RS mailing list