DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(guile.info.gz) Equality

Info Catalog (guile.info.gz) Utility Functions (guile.info.gz) Object Properties
 
 24.1 Equality
 =============
 
 Three different kinds of "sameness" are defined in Scheme.
 
    * Two values can refer to exactly the same object.
 
    * Two objects can have the same "value".
 
    * Two objects can be structurally equivalent.
 
    The differentiation between these three kinds is important, because
 determining whether two values are the same objects is very efficient,
 while determining structural equivalence can be quite expensive
 (consider comparing two very long lists).  Therefore, three different
 procedures for testing for equality are provided, which correspond to
 the three kinds of "sameness" defined above.
 
  -- Scheme Procedure: eq? x y
      Return `#t' iff X references the same object as Y.  `eq?' is
      similar to `eqv?' except that in some cases it is capable of
      discerning distinctions finer than those detectable by `eqv?'.
 
  -- Scheme Procedure: eqv? x y
      The `eqv?' procedure defines a useful equivalence relation on
      objects.  Briefly, it returns `#t' if X and Y should normally be
      regarded as the same object.  This relation is left slightly open
      to interpretation, but works for comparing immediate integers,
      characters, and inexact numbers.
 
  -- Scheme Procedure: equal? x y
      Return `#t' iff X and Y are recursively `eqv?' equivalent.
      `equal?' recursively compares the contents of pairs, vectors, and
      strings, applying `eqv?' on other objects such as numbers and
      symbols.  A rule of thumb is that objects are generally `equal?'
      if they print the same.  `equal?' may fail to terminate if its
      arguments are circular data structures.
 
Info Catalog (guile.info.gz) Utility Functions (guile.info.gz) Object Properties
automatically generated byinfo2html