[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] Procedural equivalence: the last debate

will@x scripsit:

> The plain language of the R3RS/R4RS/R5RS/IEEE rationale for eqv? also
> says "implementations are free either to detect or to fail to detect
> that two procedures or two literals are equivalent to each other,
> and can decide whether or not to merge representations of equivalent
> objects by using the same pointer or bit pattern to represent both."

I'm doing an editorial change to remove the rationale marker, then.
It's true that this is a consequence of what's above it, but it is an
RFC 2119 MAY, and shouldn't be left out if (as can in principle be done)
all the rationales were omitted.

> In Larceny/IA32, inlining the type tests for only the most common safe
> cases (symbols, booleans, the empty list, pairs) would require at
> least 11 machine instructions in addition to the 4 instructions for a
> fast call to eqv?.  To justify inlining the type test, you'd have to
> argue that the cost of increased instruction cache misses is less than
> the benefit of the inlining.

There is no need to test the safe cases, only the unsafe ones.  Assuming
that characters and fixnums are immediate, as in most high-performance
Schemes, all you need is this:

(define (eqv? x)
  (if (eq? x)
    (if (and (not (fixnum? x)) (number? x))
      (numeric-eqv? x)

Don't be so humble.  You're not that great.             John Cowan
        --Golda Meir                                    cowan@x

Scheme-reports mailing list