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

eqv? version 2



The following is my second version of the eqv? proposal, with the following
changes to address issues raised by Kent Pitman:

    eqv? on symbols is now defined in terms of string=? and symbol->string?
    instead of how the symbols print.

    eqv? on pairs, vectors, and strings is now defined in terms of the
    locations referred to by these objects instead of their creation.  This
    makes the description more precise but requires people to understand the
    domain equations and semantic equations.

(Incidentally, the formal semantics is incomplete in that it lacks axioms,
for example, that say that for any two pairs pair1 = <car1, cdr1> and
pair2 = <car2, cdr2>, one of the following must be true:

    1.  car1 = car2 & cdr1 = cdr2 & car1 != cdr1
    2.  car1 != car2 & cdr1 != cdr2 & car1 != cdr1 & car2 != cdr2

The formal semantics also lacks axioms to guarantee that, for example,
pairs never overlap with vectors.  I realized all this when I was writing
down the formal semantics, but didn't try to put it in because I felt
that people wanted the formal semantics to serve as an aid to
understanding the English descriptions rather than as a specification
in its own right.  Jonathan simplified the semantics further while preparing
it for SIGPLAN Notices.)

-------------------------------------------------------------------------------
Eliminate the second and third paragraphs of section 6.2, and
eliminate the seven bullet items that follow them.

Change the description of eqv? as follows.



(eqv? obj1 obj2)                          essential procedure

The eqv? procedure defines a useful equivalence relation on
objects.  Briefly, it returns #t if obj1 and obj2 should normally
be regarded as the same object and returns #f if they should
normally be regarded as distinct objects.  This relation is left
slightly open to interpretation, but the following partial
specification of eqv? holds for all implementations of Scheme.

The eqv? procedure returns #t if:

obj1 and obj2 are both #t or both #f.

obj1 and obj2 are both symbols and
(string=? (symbol->string obj1) (symbol->string obj2))
is true.  (Note: This assumes that neither obj1 nor obj2 is an ``uninterned
symbol'' as alluded to in section 6.4.  This report does not presume to
specify the behavior of eqv? on implementation-dependent extensions.)

obj1 and obj2 are both numbers, are numerically equal
(see =, section 6.5.4), and are either both exact or
both inexact (see section 6.5.2).

obj1 and obj2 are both characters and are the same
character according to the char=? procedure (section
6.6).

both obj1 and obj2 are the empty list.

obj1 and obj2 are pairs that refer to the same locations in the store
(see section 7.2.2).

obj1 and obj2 are vectors that refer to the same locations in the store
(see section 7.2.2).

obj1 and obj2 are strings that refer to the same locations in the store
(see section 7.2.2).

obj1 and obj2 are procedures whose location tags are equal
(see section 7.2.2).


The eqv? procedure returns #f if:

one of obj1 and obj2 is a boolean but the other is not.

one of obj1 and obj2 is a symbol but the other is not.

one of obj1 and obj2 is a number but the other is not.

one of obj1 and obj2 is a pair but the other is not.

one of obj1 and obj2 is a vector but the other is not.

one of obj1 and obj2 is a string but the other is not.

one of obj1 and obj2 is a procedure but the other is not.

one of obj1 and obj2 is #t but the other is #f.

obj1 and obj2 are symbols but
(string=? (symbol->string obj1) (symbol->string obj2)) is false.

one of obj1 and obj2 is an exact number and the other is an
inexact number.

obj1 and obj2 are numbers for which the = procedure returns
#f.

obj1 and obj2 are characters for which the char=? procedure
returns #f.

one of obj1 and obj2 is the empty list but the other is not.

obj1 and obj2 are pairs that refer to distinct locations
(see section 7.2.2).

obj1 and obj2 are vectors that refer to distinct locations
(see section 7.2.2).

obj1 and obj2 are strings that refer to distinct locations
(see section 7.2.2).

obj1 and obj2 are procedures that would behave differently
(return a different value or have different side effects)
for some arguments.

[The first block of examples goes here, omitting the
(eq? "" "") example, which should be added to the second
block of examples.]

The following examples illustrate cases in which the above
rules do not fully specify the behavior of eqv?.  In every
case, the value returned by eqv? is either #t or #f, but
which one it returns is implementation-dependent.

[The second block of examples goes here, following by the
paragraph beginning "The next set of examples shows...",
followed by the gen-counter and gen-loser examples.]

Objects of distinct types must never be regarded as the same
object, except that #f and the empty list are permitted
to be identical, and the character type need not be disjoint
from other types.

[The fourth block of examples goes here, followed by the
paragraph beginning "Since it is an error...", followed by
the fifth block of examples, followed by the note.]