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

Re: Why would anyone want opacity?

|   Date: Wed, 08 May 1996 14:37:42 +0000
|   From: William D Clinger <will@ccs.neu.edu>

|   I rarely see C or C++ or Scheme code that does not contain
|   such bugs.
|   In Scheme the analogue of the syntactic notations in C++ is
|   the use of a representation-dependent special form such as
|   CASE or the use of a representation-dependent predefined
|   procedure such as EQ?, EQV?, or EQUAL?.  These things are
|   legitimate for use with appropriate built-in types such as
|   symbols, but it is a bug to use them on any program-defined
|   ADTs outside of the module that implements the ADT.
|   These bugs are insidious, because the program may very well
|   work for the moment, but it is likely to break if anyone
|   tries to improve it.

Actually, I disagree with you here (no surprise) in one respect.

I generally agree about CASE and EQUAL?, but disagree about EQ? and
its more palatable cousin, EQV?

To me everything is an object.  What does this mean?
It means that

- its lifetime is independent of control structure
- it has identity, that is, I can distinguish between it and any other

The latter is fundamentally what EQ? provides, and thus it is never an
abstraction violation to use it.

In OO terminology, everything inherits from a class that implements
EQ?, and hence it is always available, even if you can override it.